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.settings = settings;
|
||||||
this.saveSettings = saveSettings;
|
this.saveSettings = saveSettings;
|
||||||
this.saveEnabled = false;
|
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);
|
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
|
* Save settings
|
||||||
*
|
*
|
||||||
@@ -45,12 +64,7 @@ async function saveSettings(settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reload settings
|
// reload settings
|
||||||
var response = await chrome.runtime.sendMessage({ action: "getSettings" });
|
return await getSettings();
|
||||||
if (response.status != "ok") {
|
|
||||||
throw new Error(response.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,12 +76,7 @@ async function saveSettings(settings) {
|
|||||||
*/
|
*/
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
var response = await chrome.runtime.sendMessage({ action: "getSettings" });
|
var options = new Interface(await getSettings(), saveSettings);
|
||||||
if (response.status != "ok") {
|
|
||||||
throw new Error(response.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new Interface(response.settings, saveSettings);
|
|
||||||
options.attach(document.body);
|
options.attach(document.body);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
|
Reference in New Issue
Block a user