diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/controllers/index-db-controller.js | 12 | ||||
-rw-r--r-- | library/lib/setup-iframe.js | 1 | ||||
-rw-r--r-- | library/sw-core.js | 14 |
3 files changed, 11 insertions, 16 deletions
diff --git a/library/controllers/index-db-controller.js b/library/controllers/index-db-controller.js index 3373de113..bf840b98a 100644 --- a/library/controllers/index-db-controller.js +++ b/library/controllers/index-db-controller.js @@ -58,21 +58,17 @@ module.exports = class IndexDbController extends EventEmitter { }) } - put (key, store) { - return this.requestObjectStore(key, 'readwrite') + put (state) { + return this.requestObjectStore('dataStore', 'readwrite') .then((dataObject)=> { - const putRequest = dataObject.put(store) + 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/lib/setup-iframe.js b/library/lib/setup-iframe.js index 0aa001dcf..db67163df 100644 --- a/library/lib/setup-iframe.js +++ b/library/lib/setup-iframe.js @@ -5,7 +5,6 @@ module.exports = setupIframe function setupIframe(opts) { - debugger opts = opts || {} var frame = Iframe({ src: opts.zeroClientProvider || 'https://zero.metamask.io/', diff --git a/library/sw-core.js b/library/sw-core.js index 9ceaf1dc5..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) => { @@ -141,14 +141,14 @@ function setupController (initState, client) { // storeTransform(versionifyData), // diskStore // ) - controller.store.subscribe((store) => { - dbController.put('dataStore', store) - // .then((event) => {debugger}) - // .catch((err) => {debugger}) + controller.store.subscribe((state) => { + 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 } |