Don't show default store in options on save (#96)
This commit is contained in:
@@ -20,9 +20,6 @@ function Interface(settings, saveSettings) {
|
||||
this.settings = settings;
|
||||
this.saveSettings = saveSettings;
|
||||
this.saveEnabled = false;
|
||||
|
||||
// 'default' store must not be displayed or later attempted to be saved
|
||||
delete this.settings.stores.default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,6 +27,25 @@ function handleError(error, type = "error") {
|
||||
document.body.appendChild(errorNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
*
|
||||
* @since 3.0.9
|
||||
*
|
||||
* @return object Settings object
|
||||
*/
|
||||
async function getSettings() {
|
||||
var response = await chrome.runtime.sendMessage({ action: "getSettings" });
|
||||
if (response.status != "ok") {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
// 'default' store must not be displayed or later attempted to be saved
|
||||
delete response.settings.stores.default;
|
||||
|
||||
return response.settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings
|
||||
*
|
||||
@@ -45,12 +64,7 @@ async function saveSettings(settings) {
|
||||
}
|
||||
|
||||
// reload settings
|
||||
var response = await chrome.runtime.sendMessage({ action: "getSettings" });
|
||||
if (response.status != "ok") {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
return response.settings;
|
||||
return await getSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,12 +76,7 @@ async function saveSettings(settings) {
|
||||
*/
|
||||
async function run() {
|
||||
try {
|
||||
var response = await chrome.runtime.sendMessage({ action: "getSettings" });
|
||||
if (response.status != "ok") {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
var options = new Interface(response.settings, saveSettings);
|
||||
var options = new Interface(await getSettings(), saveSettings);
|
||||
options.attach(document.body);
|
||||
} catch (e) {
|
||||
handleError(e);
|
||||
|
Reference in New Issue
Block a user