1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Check that extension.storage exists before attempting to call methods on it.

This commit is contained in:
Dan 2018-01-24 09:43:20 -03:30
parent 0164030e56
commit b7ae77f57a

View File

@ -15,12 +15,12 @@ const handleDisabledSyncAndResolve = (resolve, toResolve) => {
module.exports = class ExtensionStore {
constructor() {
this.isSupported = !!(extension.storage.sync)
this.isSupported = !!(extension.storage && extension.storage.sync)
this.isEnabled = true // TODO: get value from user settings
}
async fetch() {
return new Promise((resolve) => {
extension.storage.sync.get(KEYS_TO_SYNC, (data) => {
extension.storage && extension.storage.sync.get(KEYS_TO_SYNC, (data) => {
handleDisabledSyncAndResolve(resolve, data)
})
})
@ -31,7 +31,7 @@ module.exports = class ExtensionStore {
return result
}, {})
return new Promise((resolve) => {
extension.storage.sync.set(dataToSync, () => {
extension.storage && extension.storage.sync.set(dataToSync, () => {
handleDisabledSyncAndResolve(resolve)
})
})