From 7db099e66feeaea774e7a8c9853f5cfd3b8123eb Mon Sep 17 00:00:00 2001 From: rui hildt Date: Mon, 25 Nov 2024 14:10:53 +0100 Subject: [PATCH] Reset recommendations to update them --- src/background/main.ts | 4 ++++ src/helpers/recommendations.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/helpers/recommendations.ts 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'); + } +};