aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2018-01-24 08:26:50 +0800
committerDan Finlay <dan@danfinlay.com>2018-01-24 08:26:50 +0800
commit456dfdb9fdc0b7b0637d50808beb85ae33602f5b (patch)
tree7aa9b4e54e09b151612929571295d39d7c7297a2 /app/scripts/background.js
parent3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5 (diff)
downloadtangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.gz
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.bz2
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.lz
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.xz
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.zst
tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.zip
Modify @heyellieday's work to use storage.local to replace main storage
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index d9a2b0a6e..9790129aa 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -4,7 +4,7 @@ const pump = require('pump')
const log = require('loglevel')
const extension = require('extensionizer')
const LocalStorageStore = require('obs-store/lib/localStorage')
-const ExtensionStore = require('./lib/extension-store')
+const LocalStore = require('./lib/local-store')
const storeTransform = require('obs-store/lib/transform')
const asStream = require('obs-store/lib/asStream')
const ExtensionPlatform = require('./platforms/extension')
@@ -29,7 +29,7 @@ let popupIsOpen = false
// state persistence
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
-const extensionStore = new ExtensionStore()
+const localStore = new LocalStore()
// initialization flow
initialize().catch(log.error)
@@ -51,9 +51,10 @@ async function loadStateFromPersistence () {
let versionedData = diskStore.getState() || migrator.generateInitialState(firstTimeState)
// fetch from extension store and merge in data
- 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 }
+ if (localStore.isSupported) {
+ const localData = await localStore.get()
+ // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError)
+ versionedData = localData || versionedData
}
// migrate data
@@ -96,8 +97,8 @@ function setupController (initState) {
}
function syncDataWithExtension(state) {
- if (extensionStore.isSupported && extensionStore.isEnabled) {
- extensionStore.sync(state) // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError)
+ if (localStore.isSupported) {
+ localStore.set(state) // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError)
}
return state
}