diff options
author | Dan Finlay <dan@danfinlay.com> | 2018-03-08 06:23:31 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2018-03-08 06:23:31 +0800 |
commit | d58e47edec80180c7dd99effc229e116c63b4f57 (patch) | |
tree | ee1950f67b85d84ff35eda995f03990732c4f1cb | |
parent | 8965e59ba76e7edbb9fb48ad6f6d2665f739435f (diff) | |
download | tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar.gz tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar.bz2 tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar.lz tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar.xz tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.tar.zst tangerine-wallet-browser-d58e47edec80180c7dd99effc229e116c63b4f57.zip |
Some fixes for new storage strategy
- Don't persist undefined data
- Write to new storage strategy without waiting for completion.
- Continue writing to localStorage as fallback.
-rw-r--r-- | app/scripts/background.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index cb6810173..b5f7002dc 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -93,6 +93,9 @@ async function loadStateFromPersistence () { .catch((reason) => { log.error('Problem saving migrated data', versionedData) }) + if (versionedData) { + diskStore.putState(versionedData) + } // return just the data return versionedData.data @@ -129,6 +132,7 @@ function setupController (initState) { debounce(2000), storeTransform(versionifyData), storeTransform(syncDataWithExtension), + asStream(diskStore), (error) => { log.error('pump hit error', error) } @@ -139,14 +143,14 @@ function setupController (initState) { return versionedData } - async function syncDataWithExtension(state) { + function syncDataWithExtension(state) { if (localStore.isSupported) { - try { - await localStore.set(state) - } catch (err) { + localStore.set(state) + .catch((err) => { log.error('error setting state in local store:', err) - } + }) } else { log.error('local store not supported') } + return state } |