shaarli-web-extension/src/storage.js
2017-12-07 19:56:21 +01:00

34 lines
716 B
JavaScript

/*
Default settings. Initialize storage to these values.
*/
var storage = {
url: '',
pageAction: false,
popupWidth: 900,
popupHeight: 600,
}
/**
* Generic error logger.
* @param {object} e -
* @return {void} -
*/
function onError(e) {
console.error(e);
}
/**
* On startup, check whether we have stored settings.
* If we don't, then store the default settings.
* @param {object} storedSettings -
* @return {void} -
*/
function checkStoredSettings(storedSettings) {
if (storedSettings.url === undefined) {
browser.storage.local.set(storage);
}
}
const gettingStoredSettings = browser.storage.local.get();
gettingStoredSettings.then(checkStoredSettings, onError);