diff --git a/core/storage-manager.js b/core/storage-manager.js index d88d62f4..b5679f17 100644 --- a/core/storage-manager.js +++ b/core/storage-manager.js @@ -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(); + } }); }; diff --git a/pages/options/options-other.js b/pages/options/options-other.js index 51fa3fd5..f5414b5a 100644 --- a/pages/options/options-other.js +++ b/pages/options/options-other.js @@ -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'); } diff --git a/pages/options/options.js b/pages/options/options.js index b9cdca03..bdf12e58 100644 --- a/pages/options/options.js +++ b/pages/options/options.js @@ -155,10 +155,17 @@ options._determineOptionValues = function () { optionKeys = Object.keys(optionList); - storageManager.type.get(optionKeys, function (items) { - options._optionValues = items; - resolve(); - }); + 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({ - [optionKey]: optionValue, - }); + if (options._storageType === 'sync') { + chrome.storage.sync.set({ + [optionKey]: optionValue, + }); + } else { + chrome.storage.local.set({ + [optionKey]: optionValue, + }); + } }; options._onLinkClick = function (url) { diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 80455483..03111bc3 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -52,6 +52,10 @@
Fixed
+