aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEllie Day <heyellieday@gmail.com>2018-01-03 13:31:17 +0800
committerEllie Day <heyellieday@gmail.com>2018-01-03 13:31:17 +0800
commit7184db7632ef79d4bde0e643fdc1a4ee910c77fb (patch)
treea634f4a92faf8aa84f061eb286b1bd656c45c84f /app
parenta76324f6d397c3e746ba501cfd858c4869cb0af7 (diff)
downloadtangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar.gz
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar.bz2
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar.lz
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar.xz
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.tar.zst
tangerine-wallet-browser-7184db7632ef79d4bde0e643fdc1a4ee910c77fb.zip
handle situation where storage.sync is disabled in certain versions of firefox
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js5
-rw-r--r--app/scripts/lib/extension-store.js19
2 files changed, 19 insertions, 5 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 45da2f6d0..732f47590 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -47,11 +47,10 @@ async function initialize () {
async function loadStateFromPersistence () {
// migrations
const migrator = new Migrator({ migrations })
- // fetch from extension store
- const extensionData = await extensionStore.fetch() // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError)
// read from disk
let versionedData = diskStore.getState() || migrator.generateInitialState(firstTimeState)
- // merge extension and versioned data
+ // 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 }
// migrate data
versionedData = await migrator.migrateData(versionedData)
diff --git a/app/scripts/lib/extension-store.js b/app/scripts/lib/extension-store.js
index a8b730a65..dd0f82f36 100644
--- a/app/scripts/lib/extension-store.js
+++ b/app/scripts/lib/extension-store.js
@@ -1,11 +1,24 @@
const extension = require('extensionizer')
const KEYS_TO_SYNC = ['KeyringController', 'PreferencesController']
+const FIREFOX_SYNC_DISABLED_MESSAGE = 'Please set webextensions.storage.sync.enabled to true in about:config'
+
+const handleDisabledSyncAndResolve = (resolve, toResolve) => {
+ // Firefox 52 has sync available on extension.storage, but it is disabled by default
+ const lastError = extension.runtime.lastError
+ if (lastError && lastError.message.includes(FIREFOX_SYNC_DISABLED_MESSAGE)) {
+ resolve({})
+ } else {
+ resolve(toResolve)
+ }
+}
module.exports = class ExtensionStore {
async fetch() {
return new Promise((resolve) => {
- extension.storage.sync.get(KEYS_TO_SYNC, data => resolve(data))
+ extension.storage.sync.get(KEYS_TO_SYNC, (data) => {
+ handleDisabledSyncAndResolve(resolve, data)
+ })
})
}
async sync(state) {
@@ -14,7 +27,9 @@ module.exports = class ExtensionStore {
return result
}, {})
return new Promise((resolve) => {
- extension.storage.sync.set(dataToSync, () => resolve())
+ extension.storage.sync.set(dataToSync, () => {
+ handleDisabledSyncAndResolve(resolve)
+ })
})
}
}