Synchronize settings (#1223)
This commit is contained in:
parent
d8f6587a14
commit
2dc8c14086
|
@ -44,7 +44,9 @@ storageManager.checkStorageType = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
storageManager.migrateData = function (target) {
|
storageManager.migrateData = function (target) {
|
||||||
let storageSource, storageDestination;
|
let storageSource, storageDestination, syncFetch;
|
||||||
|
|
||||||
|
syncFetch = false;
|
||||||
|
|
||||||
if (target === 'local') {
|
if (target === 'local') {
|
||||||
storageSource = chrome.storage.sync;
|
storageSource = chrome.storage.sync;
|
||||||
|
@ -52,6 +54,11 @@ storageManager.migrateData = function (target) {
|
||||||
} else if (target === 'sync') {
|
} else if (target === 'sync') {
|
||||||
storageSource = chrome.storage.local;
|
storageSource = chrome.storage.local;
|
||||||
storageDestination = chrome.storage.sync;
|
storageDestination = chrome.storage.sync;
|
||||||
|
} else if (target === 'sync-fetch') {
|
||||||
|
storageSource = chrome.storage.sync;
|
||||||
|
storageDestination = chrome.storage.sync;
|
||||||
|
target = 'sync';
|
||||||
|
syncFetch = true;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +91,9 @@ storageManager.migrateData = function (target) {
|
||||||
[Setting.BADGE_HTML_FILTER_BACKGROUND_COLOR]: data.badgeHTMLFilterBackgroundColor,
|
[Setting.BADGE_HTML_FILTER_BACKGROUND_COLOR]: data.badgeHTMLFilterBackgroundColor,
|
||||||
[Setting.BADGE_HTML_FILTER_TEXT_COLOR]: data.badgeHTMLfilterTextColor
|
[Setting.BADGE_HTML_FILTER_TEXT_COLOR]: data.badgeHTMLfilterTextColor
|
||||||
});
|
});
|
||||||
|
if (syncFetch === true) {
|
||||||
|
chrome.runtime.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,14 @@ optionsOther._onStorageOptionChanged = function ({target}) {
|
||||||
});
|
});
|
||||||
if (target.value === 'local') {
|
if (target.value === 'local') {
|
||||||
storageManager.migrateData('local');
|
storageManager.migrateData('local');
|
||||||
|
} else {
|
||||||
|
optionsOther._fetchSyncData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
optionsOther._fetchSyncData = function () {
|
||||||
|
if (confirm('Fetch remote data now?')) {
|
||||||
|
storageManager.migrateData('sync-fetch');
|
||||||
} else {
|
} else {
|
||||||
storageManager.migrateData('sync');
|
storageManager.migrateData('sync');
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,10 +155,17 @@ options._determineOptionValues = function () {
|
||||||
|
|
||||||
optionKeys = Object.keys(optionList);
|
optionKeys = Object.keys(optionList);
|
||||||
|
|
||||||
storageManager.type.get(optionKeys, function (items) {
|
if (options._storageType === 'sync') {
|
||||||
|
chrome.storage.sync.get(optionKeys, function (items) {
|
||||||
options._optionValues = items;
|
options._optionValues = items;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
chrome.storage.local.get(optionKeys, function (items) {
|
||||||
|
options._optionValues = items;
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -278,9 +285,15 @@ options.onOptionChanged = function ({target}) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
storageManager.type.set({
|
if (options._storageType === 'sync') {
|
||||||
|
chrome.storage.sync.set({
|
||||||
[optionKey]: optionValue,
|
[optionKey]: optionValue,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
chrome.storage.local.set({
|
||||||
|
[optionKey]: optionValue,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
options._onLinkClick = function (url) {
|
options._onLinkClick = function (url) {
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>Block all non GET requests to CDN (<a href="https://codeberg.org/nobody/LocalCDN/issues/1226">#1226</a>)</li>
|
<li>Block all non GET requests to CDN (<a href="https://codeberg.org/nobody/LocalCDN/issues/1226">#1226</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>Fixed</p>
|
||||||
|
<ul>
|
||||||
|
<li>Synchronize settings (<a href="https://codeberg.org/nobody/LocalCDN/issues/1223">#1223</a>)</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="generator-section">
|
<div id="generator-section">
|
||||||
<div class="topic-label">
|
<div class="topic-label">
|
||||||
|
|
Loading…
Reference in New Issue