Skip to content

Commit 97b5f18

Browse files
committed
chore(notification): only remove from UI when delete succeeded
1 parent 77f3ab9 commit 97b5f18

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/components/notification/Notification.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { deleteNotification, resolveNotification } from "$lib/api/notification_api";
99
import type { ApiProps } from "$lib/api/api";
1010
import { notificationCount } from "$lib/components/notification/notification_store";
11+
import { getToaster } from "$lib/context/layout_context.svelte";
1112
1213
interface Props {
1314
apiProps: ApiProps
@@ -22,9 +23,11 @@
2223
$notificationCount--;
2324
}
2425
26+
const toaster = getToaster()
2527
async function remove() {
26-
await deleteNotification(apiProps, notification.id)
27-
ondelete()
28+
const result = await deleteNotification(apiProps, notification.id)
29+
if (result.ok) ondelete()
30+
else toaster.error({title: "Couldn't delete Notification", description: await result.text()})
2831
}
2932
</script>
3033

0 commit comments

Comments
 (0)