aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-15 01:49:54 +0800
committerkumavis <aaron@kumavis.me>2018-03-15 01:49:54 +0800
commitc4e90c9359de3b4c54622bde3f396bc753c9cffb (patch)
tree3b0b61d4e32f8a6ff0177392f22c989938abbdc7 /app/scripts/lib
parent39a831e2a08c1dfe6b80edc129a3ace8a2831824 (diff)
downloadtangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar.gz
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar.bz2
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar.lz
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar.xz
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.tar.zst
tangerine-wallet-browser-c4e90c9359de3b4c54622bde3f396bc753c9cffb.zip
local-store - check for error from extension.runtime
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/local-store.js31
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) {