From b7ae77f57a0e2bc68e9548364baa120805a1420c Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 24 Jan 2018 09:43:20 -0330 Subject: [PATCH] Check that extension.storage exists before attempting to call methods on it. --- app/scripts/lib/extension-store.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/extension-store.js b/app/scripts/lib/extension-store.js index 67ee71f16..4a970321c 100644 --- a/app/scripts/lib/extension-store.js +++ b/app/scripts/lib/extension-store.js @@ -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) }) })