simplify onInstalled

This commit is contained in:
tophf 2018-08-06 18:20:57 +03:00
parent 91fb0579f1
commit be94303bad

View File

@ -119,22 +119,15 @@ prefs.subscribe(['iconset'], () =>
}));
// *************************************************************************
{
const onInstall = ({reason}) => {
chrome.runtime.onInstalled.removeListener(onInstall);
if (reason === 'update') {
chrome.runtime.onInstalled.addListener(({reason}) => {
if (reason !== 'update') return;
// translations may change
localStorage.L10N = JSON.stringify({
browserUIlanguage: chrome.i18n.getUILanguage(),
});
// themes may change
delete localStorage.codeMirrorThemes;
}
};
// bind for 60 seconds max and auto-unbind if it's a normal run
chrome.runtime.onInstalled.addListener(onInstall);
setTimeout(onInstall, 60e3, {reason: 'unbindme'});
}
});
// *************************************************************************
// browser commands