From 5d8f81e13564e32263d822ece85f29d8be256090 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Fri, 2 Oct 2020 15:13:57 +0300 Subject: [PATCH] Forced data update when extension is updated --- scripts/updater.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/updater.js b/scripts/updater.js index 31ab98a..b3fbafc 100644 --- a/scripts/updater.js +++ b/scripts/updater.js @@ -3,8 +3,7 @@ let progress_interval_id = null; let update_timeout_id = null; let external_update_timeout_id = null; -checkUpdates().then(); -checkExternalUpdates().then(); +runExtension().then() browser.runtime.onMessage.addListener(function(request) { switch (request.type) { @@ -25,6 +24,15 @@ browser.runtime.onMessage.addListener(function(request) { } }); +async function runExtension() { + let version = browser.runtime.getManifest().version; + let last_version = await browser.storage.local.get('lastversion'); + if (!last_version || last_version !== version) { + await checkUpdates(true); + await checkExternalUpdates(true); + } +} + async function save(options) { const data = {}; Object.keys(options).forEach(key => {