diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-03-15 23:07:16 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-03-15 23:07:16 +0800 |
commit | cd721f52cb29e5c43e69d7c6dfbf200c971973d8 (patch) | |
tree | bc8078c76dd76eb3de9310b578239b4ccb98ab53 /app/scripts | |
parent | a087546148e5ecd10517cbbb3789d6c918e7f326 (diff) | |
parent | e2efc91aee64072c408ab509219dcbfb389c7609 (diff) | |
download | tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar.gz tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar.bz2 tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar.lz tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar.xz tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.tar.zst tangerine-wallet-browser-cd721f52cb29e5c43e69d7c6dfbf200c971973d8.zip |
Merge branch 'master' into retry-tx-refractor
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/lib/local-store.js | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/app/scripts/lib/local-store.js b/app/scripts/lib/local-store.js index 1cf00dd30..5b47985f6 100644 --- a/app/scripts/lib/local-store.js +++ b/app/scripts/lib/local-store.js @@ -3,7 +3,6 @@ // https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/local const extension = require('extensionizer') -const { promisify } = require('util') module.exports = class ExtensionStore { constructor() { @@ -11,9 +10,6 @@ module.exports = class ExtensionStore { if (!this.isSupported) { log.error('Storage local API not available.') } - const local = extension.storage.local - this._get = promisify(local.get).bind(local) - this._set = promisify(local.set).bind(local) } async get() { @@ -31,6 +27,34 @@ module.exports = class ExtensionStore { async set(state) { return this._set(state) } + + _get() { + const local = extension.storage.local + return new Promise((resolve, reject) => { + local.get(null, (result) => { + const err = extension.runtime.lastError + if (err) { + reject(err) + } else { + resolve(result) + } + }) + }) + } + + _set(obj) { + const local = extension.storage.local + return new Promise((resolve, reject) => { + local.set(obj, () => { + const err = extension.runtime.lastError + if (err) { + reject(err) + } else { + resolve() + } + }) + }) + } } function isEmpty(obj) { |