diff options
author | Ellie Day <heyellieday@gmail.com> | 2018-01-03 13:53:11 +0800 |
---|---|---|
committer | Ellie Day <heyellieday@gmail.com> | 2018-01-03 13:53:11 +0800 |
commit | 3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5 (patch) | |
tree | ae70957dfd672881ff5bcf4a67b1feb7139311bb /app/scripts | |
parent | 7184db7632ef79d4bde0e643fdc1a4ee910c77fb (diff) | |
download | tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar.gz tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar.bz2 tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar.lz tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar.xz tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.tar.zst tangerine-wallet-browser-3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5.zip |
conditionally use extension store if supported or enabled
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/background.js | 12 | ||||
-rw-r--r-- | app/scripts/lib/extension-store.js | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index 732f47590..d9a2b0a6e 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -50,8 +50,12 @@ async function loadStateFromPersistence () { // read from disk let versionedData = diskStore.getState() || migrator.generateInitialState(firstTimeState) // fetch from extension store and merge in data - const extensionData = await extensionStore.fetch() // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) - versionedData = { ...versionedData, ...extensionData } + + if (extensionStore.isSupported && extensionStore.isEnabled) { + const extensionData = await extensionStore.fetch() // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) + versionedData = { ...versionedData, ...extensionData } + } + // migrate data versionedData = await migrator.migrateData(versionedData) // write to disk @@ -92,7 +96,9 @@ function setupController (initState) { } function syncDataWithExtension(state) { - extensionStore.sync(state) // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) + if (extensionStore.isSupported && extensionStore.isEnabled) { + extensionStore.sync(state) // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) + } return state } diff --git a/app/scripts/lib/extension-store.js b/app/scripts/lib/extension-store.js index dd0f82f36..67ee71f16 100644 --- a/app/scripts/lib/extension-store.js +++ b/app/scripts/lib/extension-store.js @@ -14,6 +14,10 @@ const handleDisabledSyncAndResolve = (resolve, toResolve) => { } module.exports = class ExtensionStore { + constructor() { + this.isSupported = !!(extension.storage.sync) + this.isEnabled = true // TODO: get value from user settings + } async fetch() { return new Promise((resolve) => { extension.storage.sync.get(KEYS_TO_SYNC, (data) => { |