diff --git a/src/form.svelte b/src/form.svelte index 177dfec..39a685d 100644 --- a/src/form.svelte +++ b/src/form.svelte @@ -4,6 +4,7 @@ import {loadServerMetadata, clearCachedServerMetadata} from "./cache"; import {getProfile, updateProfile} from "./profile"; import {getConfiguration} from "./configuration"; + import {onDestroy} from 'svelte'; export let api; export let configuration; @@ -27,6 +28,7 @@ let tabInfo = null; let extensionConfiguration = null; let loading = false; + let timeoutId; $: { if (api && configuration) { @@ -116,7 +118,17 @@ saveState = "loading"; await api.saveBookmark(bookmark); await clearCachedServerMetadata(); + + const tabInfo = await getCurrentTabInfo(); + showBadge(tabInfo.id) + + // Show success state, then reset it after a short delay saveState = "success"; + timeoutId = setTimeout(() => { + saveState = ""; + bookmarkExists = true; + }, 1500); + // Show star badge on the tab to indicate that it's now bookmarked // but only if precaching is enabled, since the badge will never // show when browsing without precaching @@ -130,6 +142,12 @@ } } + onDestroy(() => { + if (timeoutId) { + clearTimeout(timeoutId); + } + }); + function handleOptions() { openOptions(); }