From 302a1029bd955f58916a498cb782e702aa50602c Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 8 Mar 2017 18:14:43 -0500 Subject: [PATCH] Simplify developer menu logic --- js/lbry.js | 15 ++++++--------- js/page/developer.js | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/js/lbry.js b/js/lbry.js index d70f53089..b730d4cee 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -18,7 +18,7 @@ var lbry = { debug: false, useCustomLighthouseServers: false, customLighthouseServers: [], - menu: 'normal', + showDeveloperMenubar: false, } }; @@ -560,15 +560,12 @@ lbry.fileInfoUnsubscribe = function(name, subscribeId) { } lbry.showMenuIfNeeded = function() { - const showingMenu = sessionStorage.getItem('menuShown'); - const chosenMenu = lbry.getClientSetting('menu'); - if (!showingMenu || showingMenu != chosenMenu) { - if (chosenMenu == 'normal') { - menu.showNormalMenubar(); - } else { - menu.showDeveloperMenubar(); - } + const showingMenu = sessionStorage.getItem('menuShown') || null; + const chosenMenu = lbry.getClientSetting('showDeveloperMenu') ? 'developer' : 'normal'; + if (chosenMenu != showingMenu) { + menu.showMenubar(chosenMenu == 'developer'); } + sessionStorage.setItem('menuShown', chosenMenu); }; export default lbry; diff --git a/js/page/developer.js b/js/page/developer.js index afe837db0..88a45542d 100644 --- a/js/page/developer.js +++ b/js/page/developer.js @@ -5,13 +5,13 @@ import FormField from '../component/form.js'; const DeveloperPage = React.createClass({ getInitialState: function() { return { - showDeveloperMenu: lbry.getClientSetting('menu') == 'developer', + showDeveloperMenu: lbry.getClientSetting('showDeveloperMenu'), useCustomLighthouseServers: lbry.getClientSetting('useCustomLighthouseServers'), customLighthouseServers: lbry.getClientSetting('customLighthouseServers').join('\n'), }; }, handleShowDeveloperMenuChange: function(event) { - lbry.setClientSetting('menu', event.target.checked ? 'developer' : 'normal'); + lbry.setClientSetting('showDeveloperMenu', event.target.checked); lbry.showMenuIfNeeded(); this.setState({ showDeveloperMenu: event.target.checked,