Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Save pref only if it's different from the old pref
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Gerber committed Sep 10, 2014
1 parent 37aeb25 commit 8a29009
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/extensions/default/DebugCommands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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));
});

/*
Expand Down

0 comments on commit 8a29009

Please sign in to comment.