diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-03-24 02:41:32 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-03-24 02:41:32 +0800 |
commit | 197e6e0b77868b0bec76cef303b2eeffda5797bf (patch) | |
tree | 510fb27393318dcbcaaccb5331ad7d57088345fe /library | |
parent | 45ab81fb45ec1043d617f66c308e2e7911c8e0ad (diff) | |
download | tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar.gz tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar.bz2 tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar.lz tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar.xz tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.tar.zst tangerine-wallet-browser-197e6e0b77868b0bec76cef303b2eeffda5797bf.zip |
WIP: indexdb is at an err state "provider is undefined"
Diffstat (limited to 'library')
-rw-r--r-- | library/controllers/index-db-controller.js | 32 | ||||
-rw-r--r-- | library/lib/setup-iframe.js | 1 | ||||
-rw-r--r-- | library/sw-core.js | 4 |
3 files changed, 26 insertions, 11 deletions
diff --git a/library/controllers/index-db-controller.js b/library/controllers/index-db-controller.js index 3373de113..f7225c00b 100644 --- a/library/controllers/index-db-controller.js +++ b/library/controllers/index-db-controller.js @@ -51,19 +51,35 @@ module.exports = class IndexDbController extends EventEmitter { return this.requestObjectStore(key) .then((dataObject)=> { return new Promise((resolve, reject) => { - const getRequest = dataObject.get(key) - getRequest.onsuccess = (event) => resolve(event.currentTarget.result) - getRequest.onerror = (event) => reject(event) + const getRequest = dataObject.get(key) + getRequest.onsuccess = (event) => { + const serialized = event.currentTarget.result + try { + console.log('serialized:',serialized) + const state = serialized ? JSON.parse(serialized) : {} + resolve(state) + } catch (err) { + reject(err) + } + } + getRequest.onerror = (event) => reject(event) + }) }) - }) } - put (key, store) { + put (key, state) { return this.requestObjectStore(key, 'readwrite') .then((dataObject)=> { - const putRequest = dataObject.put(store) - putRequest.onsuccess = (event) => Promise.resolve(event.currentTarget.result) - putRequest.onerror = (event) => Promise.reject(event) + 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) + } + }) }) } 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..60fc88039 100644 --- a/library/sw-core.js +++ b/library/sw-core.js @@ -141,8 +141,8 @@ function setupController (initState, client) { // storeTransform(versionifyData), // diskStore // ) - controller.store.subscribe((store) => { - dbController.put('dataStore', store) + controller.store.subscribe((state) => { + dbController.put('dataStore', state) // .then((event) => {debugger}) // .catch((err) => {debugger}) }) |