aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-04-18 09:14:28 +0000
committerFuwn <[email protected]>2026-04-18 09:14:28 +0000
commitb7ed85e23ff89a41cd43aed44fbc6fa2c54f9aa2 (patch)
tree2e71c94f09a217a44eb1d861293e290b41825dee
parentfix(settings): catch errors in settings sync fetch chains (diff)
downloaddue.moe-b7ed85e23ff89a41cd43aed44fbc6fa2c54f9aa2.tar.xz
due.moe-b7ed85e23ff89a41cd43aed44fbc6fa2c54f9aa2.zip
fix(notification): clear auto-dismiss timer on component destroy
onMount scheduled a setTimeout to auto-dismiss the notification after notification.duration ms but never stored the handle. If the component was destroyed before the timer fired (parent unmount, navigation), the timer still ran and called remove() on a stale closure. Capture the timer id and clear it from the onMount cleanup callback.
-rw-r--r--src/lib/Notification/Notification.svelte6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/Notification/Notification.svelte b/src/lib/Notification/Notification.svelte
index 76775ff3..a3271d58 100644
--- a/src/lib/Notification/Notification.svelte
+++ b/src/lib/Notification/Notification.svelte
@@ -9,7 +9,11 @@ export let onRemove: () => void = () => {
};
export let removed = false;
-onMount(() => setTimeout(remove, notification.duration));
+onMount(() => {
+ const removeTimer = setTimeout(remove, notification.duration);
+
+ return () => clearTimeout(removeTimer);
+});
const remove = () => {
removed = true;