Skip to content

Commit

Permalink
Allow updating bookmark immediately after save
Browse files Browse the repository at this point in the history
Currently, after saving a bookmark, there is no way to submit updates
without closing the extension dialog and reopening it. This makes it
possible to submit updates to the bookmark without reopening the
extension.

Also:
- Shows the star badge on the extension icon immediately after a
successful save
- Displays the "This URL is already bookmarked." message after the
save success state resets

Similar to the logic in the closed pull request sissbruecker#46. May resolve sissbruecker#13.
  • Loading branch information
AdamVig committed Dec 6, 2024
1 parent 2b9c49c commit e6fb518
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@
let tabInfo = null;
let extensionConfiguration = null;
let loading = false;
let timeoutId;
$: {
if (api && configuration) {
Expand Down Expand Up @@ -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
Expand All @@ -130,6 +142,12 @@
}
}
onDestroy(() => {
if (timeoutId) {
clearTimeout(timeoutId);
}
});
function handleOptions() {
openOptions();
}
Expand Down

0 comments on commit e6fb518

Please sign in to comment.