Skip to content

Commit

Permalink
Bug fix: Menu items for clippings and folders are duplicated
Browse files Browse the repository at this point in the history
every time the background script is restarted (part of issue #388)
  • Loading branch information
aecreations committed May 20, 2024
1 parent 67dc0e4 commit b3e4b66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wx-src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ browser.runtime.onInstalled.addListener(async (aInstall) => {
browser.runtime.onStartup.addListener(async () => {
log("Clippings/wx: Resetting persistent background script data during browser startup");
await aePrefs.setPrefs({
_isInitialized: false,
_clippingMenuItemIDMap: {},
_folderMenuItemIDMap: {},
_autoIncrPlchldrs: [],
Expand Down Expand Up @@ -423,10 +424,14 @@ async function init(aPrefs)

if (aPrefs.syncClippings) {
// The context menu will be built when refreshing the sync data.
// Do this even when the background script is restarted in order to pick up
// any changes to sync data.
refreshSyncedClippings(true);
}
else {
buildContextMenu(platform.os, aPrefs);
if (! aPrefs._isInitialized) {
buildContextMenu(platform.os, aPrefs);
}
}

aeClippingSubst.init(navigator.userAgent, aPrefs.autoIncrPlcHldrStartVal);
Expand Down Expand Up @@ -478,6 +483,8 @@ async function init(aPrefs)
else {
log("Clippings/wx: Initialization complete.");
}

await aePrefs.setPrefs({_isInitialized: true});
}


Expand Down
1 change: 1 addition & 0 deletions wx-src/scripts/aePrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
let aePrefs = {
_defaultPrefs: {
// Background script state persistence
_isInitialized: false,
_clippingMenuItemIDMap: {},
_folderMenuItemIDMap: {},
_autoIncrPlchldrs: [],
Expand Down

0 comments on commit b3e4b66

Please sign in to comment.