Start extension after all index has been updated

This commit is contained in:
Folyd 2023-04-09 12:22:29 +08:00
parent fe3a501251
commit 72c2a94787

View file

@ -11,7 +11,7 @@ function getPlatformOs() {
}); });
} }
(async () => { async function start() {
// All dynamic setting items. Those items will been updated // All dynamic setting items. Those items will been updated
// in chrome.storage.onchange listener callback. // in chrome.storage.onchange listener callback.
let isOfflineMode = await settings.isOfflineMode; let isOfflineMode = await settings.isOfflineMode;
@ -536,7 +536,7 @@ function getPlatformOs() {
} }
return true; return true;
}); });
})(); }
const chromeAction = chrome.action || chrome.browserAction; const chromeAction = chrome.action || chrome.browserAction;
chromeAction.onClicked.addListener(() => { chromeAction.onClicked.addListener(() => {
@ -544,9 +544,11 @@ chromeAction.onClicked.addListener(() => {
chrome.tabs.create({ url: managePage }); chrome.tabs.create({ url: managePage });
}); });
chrome.runtime.onInstalled.addListener(({ previousVersion, reason }) => { chrome.runtime.onInstalled.addListener(async ({ previousVersion, reason }) => {
if (reason === "update" && previousVersion !== manifest.version) { if (reason === "update" && previousVersion !== manifest.version) {
IndexManager.updateAllIndex(); IndexManager.updateAllIndex();
console.log(`New version updated! Previous version: ${previousVersion}, new version: ${manifest.version}`); console.log(`New version updated! Previous version: ${previousVersion}, new version: ${manifest.version}`);
} }
await start()
}); });