Remove by id only

Signed-off-by: Marcus Eide <eide@spotify.com>
This commit is contained in:
Marcus Eide
2021-04-30 09:53:30 +02:00
parent a4c5361c0e
commit de6c739401
4 changed files with 5 additions and 9 deletions
+1 -5
View File
@@ -86,11 +86,7 @@ describe('EditShortcut', () => {
fireEvent.click(screen.getByText('Remove'));
await waitFor(() => {
expect(spy).toBeCalledWith({
id: 'id',
title: 'some title',
url: '/some-url',
});
expect(spy).toBeCalledWith('id');
});
});
+1 -1
View File
@@ -78,7 +78,7 @@ export const EditShortcut = ({ shortcut, onClose, anchorEl, api }: Props) => {
const handleRemove = async () => {
try {
await api.remove(shortcut);
await api.remove(shortcut.id);
alertApi.post({
message: `Removed shortcut '${shortcut.title}' from your sidebar`,
severity: 'success',
@@ -39,8 +39,8 @@ export class LocalStoredShortcuts implements ShortcutApi {
this.notify();
}
async remove(shortcut: Shortcut) {
const shortcuts = this.get().filter(s => s.id !== shortcut.id);
async remove(id: string) {
const shortcuts = this.get().filter(s => s.id !== id);
await this.storageApi.set('items', shortcuts);
this.notify();
+1 -1
View File
@@ -36,7 +36,7 @@ export interface ShortcutApi {
/**
* Removes the shortcut.
*/
remove(shortcut: Shortcut): Promise<void>;
remove(id: string): Promise<void>;
/**
* Finds an existing shortcut that matches the ID of the