diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-03-24 05:24:06 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-03-24 05:24:06 +0800 |
commit | 54e157020e0c57bef336480181e5235396bfd2c0 (patch) | |
tree | a026cc5dc7f2f1f67777c176c0a42ec345a393a1 /library | |
parent | 197e6e0b77868b0bec76cef303b2eeffda5797bf (diff) | |
parent | 412cc2394a89a3ba1c0ca82cecf03c29254b7381 (diff) | |
download | tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar.gz tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar.bz2 tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar.lz tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar.xz tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.tar.zst tangerine-wallet-browser-54e157020e0c57bef336480181e5235396bfd2c0.zip |
Merge branch 'mascaraMix' into mascara
Diffstat (limited to 'library')
-rw-r--r-- | library/controllers/index-db-controller.js | 23 | ||||
-rw-r--r-- | library/sw-core.js | 12 |
2 files changed, 12 insertions, 23 deletions
diff --git a/library/controllers/index-db-controller.js b/library/controllers/index-db-controller.js index f7225c00b..4c03eca46 100644 --- a/library/controllers/index-db-controller.js +++ b/library/controllers/index-db-controller.js @@ -67,28 +67,17 @@ module.exports = class IndexDbController extends EventEmitter { }) } - put (key, state) { - return this.requestObjectStore(key, 'readwrite') + put (state) { + return this.requestObjectStore('dataStore', 'readwrite') .then((dataObject)=> { - return new Promise((resolve, reject) => { - try { - const serialized = JSON.stringify(state) - const putRequest = dataObject.put(serialized) - putRequest.onsuccess = (event) => resolve(event.currentTarget.result) - putRequest.onerror = (event) => reject(event) - } catch (err) { - reject(err) - } - }) + const putRequest = dataObject.put(state, 'dataStore') + putRequest.onsuccess = (event) => Promise.resolve(event.currentTarget.result) + putRequest.onerror = (event) => Promise.reject(event) }) } - update (key, value) { - - } - migrate () { - this.db.createObjectStore(this.name) + this.db.createObjectStore('dataStore') } _add (key, objStore, cb = logger) { diff --git a/library/sw-core.js b/library/sw-core.js index 60fc88039..3972e361b 100644 --- a/library/sw-core.js +++ b/library/sw-core.js @@ -87,7 +87,7 @@ function loadStateFromPersistence() { const initialState = migrator.generateInitialState(firstTimeState) dbController.initialState = initialState return dbController.open() - .then((stuff) => { + .then((openRequest) => { return dbController.get('dataStore') }) .then((data) => { @@ -142,13 +142,13 @@ function setupController (initState, client) { // diskStore // ) controller.store.subscribe((state) => { - dbController.put('dataStore', state) - // .then((event) => {debugger}) - // .catch((err) => {debugger}) + dbController.put(versionifyData(controller.store)) + .catch((err) => {console.error(err)}) }) function versionifyData(state) { - let versionedData = diskStore.getState() - versionedData.data = state + // let versionedData = diskStore.getState() + // versionedData.data = state + let versionedData = {data: state} return versionedData } |