options
This commit is contained in:
parent
200b8f6b75
commit
592f15f96c
@ -189,36 +189,22 @@ function optionsVersion(options) {
|
|||||||
|
|
||||||
function optionsLoad() {
|
function optionsLoad() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (chrome.storage.sync) {
|
chrome.storage.local.get(null, store => resolve(store.options));
|
||||||
chrome.storage.sync.getBytesInUse(null, resolve);
|
}).then(optionsStr => {
|
||||||
} else {
|
if (optionsStr) {
|
||||||
resolve(0);
|
return JSON.parse(optionsStr);
|
||||||
}
|
} else if (chrome.storage.sync) {
|
||||||
}).then(bytes => {
|
|
||||||
if (bytes === 0) {
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.local.get(null, store => {
|
chrome.storage.sync.get(null, options => resolve(options));
|
||||||
let options = {};
|
|
||||||
try {
|
|
||||||
options = JSON.parse(store.options);
|
|
||||||
} catch (e) {
|
|
||||||
// NOP
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(optionsVersion(options));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve, reject) => {
|
return {};
|
||||||
chrome.storage.sync.get(null, options => resolve(optionsVersion(options)));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
return {};
|
||||||
}).then(options => {
|
}).then(options => {
|
||||||
if (chrome.storage.sync) {
|
return optionsVersion(options);
|
||||||
chrome.storage.sync.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user