diff options
local-store - check for error from extension.runtime
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/local-store.js | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/app/scripts/lib/local-store.js b/app/scripts/lib/local-store.js index 2d6155dbf..175126d86 100644 --- a/app/scripts/lib/local-store.js +++ b/app/scripts/lib/local-store.js @@ -10,9 +10,6 @@ module.exports = class ExtensionStore { if (!this.isSupported) { log.error('Storage local API not available.') } - const local = extension.storage.local - this._get = function() { return new Promise((resolve) => local.get(resolve)) } - this._set = function(state) { return new Promise((resolve) => local.set(state, resolve)) } } async get() { @@ -30,6 +27,34 @@ module.exports = class ExtensionStore { async set(state) { return this._set(state) } + + function _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) + } + }) + }) + } + + function _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) { |