diff --git a/src/background/main.ts b/src/background/main.ts index 1a38d5ff..87b14e7b 100644 --- a/src/background/main.ts +++ b/src/background/main.ts @@ -1,5 +1,6 @@ import { addExtensionsListeners } from '@/helpers/extensions'; import { initProxyListeners } from '@/helpers/proxyListeners'; +import { resetRecommendations } from '@/helpers/recommendations'; // only on dev mode if (import.meta.hot) { @@ -7,6 +8,9 @@ if (import.meta.hot) { import('/@vite/client'); } +// Add listeners to execute on subsequent updates +resetRecommendations(); + // Add listeners on extension actions addExtensionsListeners(); diff --git a/src/helpers/recommendations.ts b/src/helpers/recommendations.ts new file mode 100644 index 00000000..1dd211f0 --- /dev/null +++ b/src/helpers/recommendations.ts @@ -0,0 +1,16 @@ +import browser from 'webextension-polyfill'; + +export const clearStorageKey = async (key: string) => { + await browser.storage.local.remove(key); +}; + +// Reset recommendations to update them +// We'll keep that for 0.9.4, then we'll remove it +export const resetRecommendations = async () => { + const manifest = browser.runtime.getManifest(); + const currentVersion = manifest.version; + + if (currentVersion === '0.9.4') { + await clearStorageKey('recommendations'); + } +};