mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 18:41:38 +01:00
Check that extension.storage exists before attempting to call methods on it.
This commit is contained in:
parent
0164030e56
commit
b7ae77f57a
@ -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)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user