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