prefs.js (1046B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 "use strict"; 5 6 const { 7 EAGER_EVALUATION_TOGGLE, 8 GROUP_SIMILAR_MESSAGES_TOGGLE, 9 AUTOCOMPLETE_TOGGLE, 10 } = require("resource://devtools/client/webconsole/constants.js"); 11 12 const PrefState = overrides => 13 Object.freeze( 14 Object.assign( 15 { 16 logLimit: 1000, 17 sidebarToggle: false, 18 groupSimilar: false, 19 autocomplete: false, 20 eagerEvaluation: false, 21 historyCount: 50, 22 }, 23 overrides 24 ) 25 ); 26 27 const dict = { 28 [EAGER_EVALUATION_TOGGLE]: "eagerEvaluation", 29 [GROUP_SIMILAR_MESSAGES_TOGGLE]: "groupSimilar", 30 [AUTOCOMPLETE_TOGGLE]: "autocomplete", 31 }; 32 33 function prefs(state = PrefState(), action) { 34 const pref = dict[action.type]; 35 if (pref) { 36 return { 37 ...state, 38 [pref]: !state[pref], 39 }; 40 } 41 42 return state; 43 } 44 45 module.exports = { 46 PrefState, 47 prefs, 48 };