initial code for migration from sync storage to local storage
This commit is contained in:
parent
6b6190ade7
commit
974b103409
@ -188,22 +188,29 @@ function optionsVersion(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function optionsLoad() {
|
function optionsLoad() {
|
||||||
if (!chrome.storage.sync) {
|
|
||||||
chrome.storage.sync = chrome.storage.local;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.sync.get(null, options => resolve(optionsVersion(options)));
|
if (chrome.storage.sync) {
|
||||||
|
chrome.storage.sync.getBytesInUse(null, resolve);
|
||||||
|
} else {
|
||||||
|
resolve(0);
|
||||||
|
}
|
||||||
|
}).then(bytes => {
|
||||||
|
const storage = bytes === 0 ? chrome.storage.local : chrome.storage.sync;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
storage.get(null, options => resolve(optionsVersion(options)));
|
||||||
|
});
|
||||||
|
}).then(options => {
|
||||||
|
if (chrome.storage.sync) {
|
||||||
|
chrome.storage.sync.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionsSave(options) {
|
function optionsSave(options) {
|
||||||
if (!chrome.storage.sync) {
|
|
||||||
chrome.storage.sync = chrome.storage.local;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.sync.set(options, resolve);
|
chrome.storage.local.set(options, resolve);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
instYomi().optionsSet(options);
|
instYomi().optionsSet(options);
|
||||||
fgOptionsSet(options);
|
fgOptionsSet(options);
|
||||||
|
Loading…
Reference in New Issue
Block a user