aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2018-03-08 06:42:59 +0800
committerDan Finlay <dan@danfinlay.com>2018-03-08 06:42:59 +0800
commit64fcd271028ff57c34dd930b76ce23081eff814a (patch)
tree114ebba1436fdb5ed4545cf564b868aff1dc5a2a /app
parentb97ac5106fd8479a81dc5c32ede99090427ee1b8 (diff)
downloadtangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar.gz
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar.bz2
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar.lz
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar.xz
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.tar.zst
tangerine-wallet-browser-64fcd271028ff57c34dd930b76ce23081eff814a.zip
Tighten up data loading code
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 55eeed83f..e8a7594ac 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -68,10 +68,10 @@ async function initialize () {
async function loadStateFromPersistence () {
// migrations
const migrator = new Migrator({ migrations })
- // read from disk
- versionedData = diskStore.getState() || migrator.generateInitialState(firstTimeState)
- // fetch from extension store and merge in data
+ // read from disk
+ // first from preferred, async API:
+ let localStoreData
if (localStore.isSupported) {
let localData
try {
@@ -82,10 +82,14 @@ async function loadStateFromPersistence () {
// If localStore is supported but has not been written to yet, ignore:
if (Object.keys(localData).length > 0) {
- versionedData = localData
+ localStoreData = localData
}
}
+ versionedData = localStoreData ||
+ diskStore.getState() ||
+ migrator.generateInitialState(firstTimeState)
+
// migrate data
versionedData = await migrator.migrateData(versionedData)