init logic for basic settings
This commit is contained in:
parent
8c79c437c9
commit
8d433afa45
12
bg.js
12
bg.js
@ -1,12 +1,13 @@
|
||||
browser.runtime.onInstalled.addListener((ev) => {
|
||||
if (ev.reason == "update") {
|
||||
initialiseSettings();
|
||||
updateIsSignificant(ev.previousVersion).then(
|
||||
v => {
|
||||
if (v) launchInfoPage();
|
||||
}
|
||||
)
|
||||
} else if (ev.reason == "install") {
|
||||
browser.runtime.openOptionsPage()
|
||||
initialiseSettings().then(() => browser.runtime.openOptionsPage());
|
||||
}
|
||||
})
|
||||
|
||||
@ -17,4 +18,11 @@ async function updateIsSignificant(previousVersion) {
|
||||
}
|
||||
function launchInfoPage(){
|
||||
browser.tabs.create({url: "/changelog.htm", active: false})
|
||||
}
|
||||
}
|
||||
|
||||
async function initialiseSettings(){
|
||||
let defaultSettings = {"enable": true, "showChangelog": true};
|
||||
const presentSettings = await browser.storage.sync.get();
|
||||
defaultSettings = Object.fromEntries(Object.entries(defaultSettings).filter((k, v) => !(k in presentSettings)));
|
||||
await browser.storage.sync.set(defaultSettings);
|
||||
}
|
Loading…
Reference in New Issue
Block a user