Skip to content

Commit

Permalink
Throttle update notifications
Browse files Browse the repository at this point in the history
- Prevents tab from spamming when simply reloading the extension
  • Loading branch information
killergerbah committed Feb 26, 2024
1 parent 434f3d3 commit 738af93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ const updateListener = async (details: chrome.runtime.InstalledDetails) => {
return;
}

chrome.tabs.create({ url: `${chrome.runtime.getURL('ftue-ui.html')}?update=true`, active: true });
const lastUpdateNotifVersion = (await chrome.storage.local.get('lastUpdateNotifVersion')).lastUpdateNotifVersion;
const currentVersion = chrome.runtime.getManifest().version;

if (lastUpdateNotifVersion !== currentVersion) {
chrome.tabs.create({ url: `${chrome.runtime.getURL('ftue-ui.html')}?update=true`, active: true });
await chrome.storage.local.set({ lastUpdateNotifVersion: currentVersion });
}
};

chrome.runtime.onInstalled.addListener(installListener);
Expand Down

0 comments on commit 738af93

Please sign in to comment.