From 37aeb2589ab51c82e221dd3370fca8cc7fcebe7d Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Wed, 10 Sep 2014 00:20:11 +0200 Subject: [PATCH 1/2] Make "Show Errors in Status Bar" pref more solid --- src/extensions/default/DebugCommands/main.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/extensions/default/DebugCommands/main.js b/src/extensions/default/DebugCommands/main.js index 6d84c4d3431..e3be5bdad66 100644 --- a/src/extensions/default/DebugCommands/main.js +++ b/src/extensions/default/DebugCommands/main.js @@ -237,7 +237,7 @@ define(function (require, exports, module) { }); } - function toggleErrorNotification(bool) { + function toggleErrorNotification(bool, doNotSave) { var val; if (typeof bool === "undefined") { @@ -250,7 +250,9 @@ define(function (require, exports, module) { // update menu CommandManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR).setChecked(val); - PreferencesManager.set(DEBUG_SHOW_ERRORS_IN_STATUS_BAR, val); + if (!doNotSave) { + PreferencesManager.set(DEBUG_SHOW_ERRORS_IN_STATUS_BAR, val); + } } function handleOpenBracketsSource() { @@ -287,7 +289,11 @@ define(function (require, exports, module) { CommandManager.register(Strings.CMD_RESTART_NODE, DEBUG_RESTART_NODE, NodeDebugUtils.restartNode); enableRunTestsMenuItem(); - toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR)); + toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR), true); + + PreferencesManager.on("change", DEBUG_SHOW_ERRORS_IN_STATUS_BAR, function () { + toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR), true); + }); /* * Debug menu From 8a29009e12321dd49d0cdfd7ba4c9408a17cc60c Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Wed, 10 Sep 2014 13:57:04 +0200 Subject: [PATCH 2/2] Save pref only if it's different from the old pref --- src/extensions/default/DebugCommands/main.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/extensions/default/DebugCommands/main.js b/src/extensions/default/DebugCommands/main.js index e3be5bdad66..137d55582d5 100644 --- a/src/extensions/default/DebugCommands/main.js +++ b/src/extensions/default/DebugCommands/main.js @@ -237,11 +237,12 @@ define(function (require, exports, module) { }); } - function toggleErrorNotification(bool, doNotSave) { - var val; + function toggleErrorNotification(bool) { + var val, + oldPref = !!PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR); - if (typeof bool === "undefined") { - val = !PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR); + if (bool === undefined) { + val = !oldPref; } else { val = !!bool; } @@ -250,7 +251,7 @@ define(function (require, exports, module) { // update menu CommandManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR).setChecked(val); - if (!doNotSave) { + if (val !== oldPref) { PreferencesManager.set(DEBUG_SHOW_ERRORS_IN_STATUS_BAR, val); } } @@ -289,10 +290,10 @@ define(function (require, exports, module) { CommandManager.register(Strings.CMD_RESTART_NODE, DEBUG_RESTART_NODE, NodeDebugUtils.restartNode); enableRunTestsMenuItem(); - toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR), true); + toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR)); PreferencesManager.on("change", DEBUG_SHOW_ERRORS_IN_STATUS_BAR, function () { - toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR), true); + toggleErrorNotification(PreferencesManager.get(DEBUG_SHOW_ERRORS_IN_STATUS_BAR)); }); /*