From 3af310c3412d7f2f1e565d354191ea814731effa Mon Sep 17 00:00:00 2001 From: eight Date: Thu, 4 Oct 2018 17:09:26 +0800 Subject: [PATCH] Fix: open-manager has no default value --- background/background.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/background/background.js b/background/background.js index 840f7b8b..e2bf4fef 100644 --- a/background/background.js +++ b/background/background.js @@ -202,11 +202,10 @@ if (chrome.contextMenus) { } item = Object.assign({id}, item); delete item.presentIf; - const prefValue = prefs.get(id); item.title = chrome.i18n.getMessage(item.title); - if (!item.type && typeof prefValue === 'boolean') { + if (!item.type && typeof prefs.defaults[id] === 'boolean') { item.type = 'checkbox'; - item.checked = prefValue; + item.checked = prefs.get(id); } if (!item.contexts) { item.contexts = ['browser_action']; @@ -230,7 +229,7 @@ if (chrome.contextMenus) { }; const keys = Object.keys(contextMenus); - prefs.subscribe(keys.filter(id => typeof prefs.get(id) === 'boolean'), toggleCheckmark); + prefs.subscribe(keys.filter(id => typeof prefs.defaults[id] === 'boolean'), toggleCheckmark); prefs.subscribe(keys.filter(id => contextMenus[id].presentIf), togglePresence); createContextMenus(keys); }