Skip to content

Commit

Permalink
Reset recommendations to update them
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt committed Nov 25, 2024
1 parent c1540cd commit 7db099e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/background/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { addExtensionsListeners } from '@/helpers/extensions';
import { initProxyListeners } from '@/helpers/proxyListeners';
import { resetRecommendations } from '@/helpers/recommendations';

// only on dev mode
if (import.meta.hot) {
// @ts-expect-error for background HMR
import('/@vite/client');
}

// Add listeners to execute on subsequent updates
resetRecommendations();

// Add listeners on extension actions
addExtensionsListeners();

Expand Down
16 changes: 16 additions & 0 deletions src/helpers/recommendations.ts
Original file line number Diff line number Diff line change
@@ -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');
}
};

0 comments on commit 7db099e

Please sign in to comment.