Bug 1419410 Removes Immutable usage in UI reducer; r?nchevobbe draft
authorSudheesh Singanamalla <sudheesh1995@outlook.com>
Thu, 23 Nov 2017 21:09:48 +0530
changeset 702663 4d3d798c19646efdc08ba915520271c8763fb312
parent 702588 b6bed1b710c3e22cab49f22f1b5f44d80286bcb9
child 741552 b95947995de6ab2f181a05b42414b27df1abb10e
push id90578
push userbmo:sudheesh1995@yahoo.com
push dateThu, 23 Nov 2017 15:40:37 +0000
reviewersnchevobbe
bugs1419410
milestone59.0a1
Bug 1419410 Removes Immutable usage in UI reducer; r?nchevobbe MozReview-Commit-ID: 76xdMKBGIUU
devtools/client/webconsole/new-console-output/actions/ui.js
devtools/client/webconsole/new-console-output/reducers/ui.js
devtools/client/webconsole/new-console-output/store.js
--- a/devtools/client/webconsole/new-console-output/actions/ui.js
+++ b/devtools/client/webconsole/new-console-output/actions/ui.js
@@ -20,27 +20,27 @@ const {
 } = require("devtools/client/webconsole/new-console-output/constants");
 
 function filterBarToggle(show) {
   return (dispatch, getState) => {
     dispatch({
       type: FILTER_BAR_TOGGLE,
     });
     const uiState = getAllUi(getState());
-    Services.prefs.setBoolPref(PREFS.UI.FILTER_BAR, uiState.get("filterBarVisible"));
+    Services.prefs.setBoolPref(PREFS.UI.FILTER_BAR, uiState.filterBarVisible);
   };
 }
 
 function persistToggle(show) {
   return (dispatch, getState) => {
     dispatch({
       type: PERSIST_TOGGLE,
     });
     const uiState = getAllUi(getState());
-    Services.prefs.setBoolPref(PREFS.UI.PERSIST, uiState.get("persistLogs"));
+    Services.prefs.setBoolPref(PREFS.UI.PERSIST, uiState.persistLogs);
   };
 }
 
 function timestampsToggle(visible) {
   return {
     type: TIMESTAMPS_TOGGLE,
     visible,
   };
--- a/devtools/client/webconsole/new-console-output/reducers/ui.js
+++ b/devtools/client/webconsole/new-console-output/reducers/ui.js
@@ -8,45 +8,44 @@
 const {
   FILTER_BAR_TOGGLE,
   INITIALIZE,
   PERSIST_TOGGLE,
   SELECT_NETWORK_MESSAGE_TAB,
   SIDEBAR_TOGGLE,
   TIMESTAMPS_TOGGLE,
 } = require("devtools/client/webconsole/new-console-output/constants");
-const Immutable = require("devtools/client/shared/vendor/immutable");
 
 const {
   PANELS,
 } = require("devtools/client/netmonitor/src/constants");
 
-const UiState = Immutable.Record({
+const UiState = (overrides) => Object.freeze(Object.assign({
   filterBarVisible: false,
   initialized: false,
   networkMessageActiveTabId: PANELS.HEADERS,
   persistLogs: false,
   sidebarVisible: false,
   timestampsVisible: true,
-});
+}, overrides));
 
-function ui(state = new UiState(), action) {
+function ui(state = UiState(), action) {
   switch (action.type) {
     case FILTER_BAR_TOGGLE:
-      return state.set("filterBarVisible", !state.filterBarVisible);
+      return Object.assign({}, state, {filterBarVisible: !state.filterBarVisible});
     case PERSIST_TOGGLE:
-      return state.set("persistLogs", !state.persistLogs);
+      return Object.assign({}, state, {persistLogs: !state.persistLogs});
     case TIMESTAMPS_TOGGLE:
-      return state.set("timestampsVisible", action.visible);
+      return Object.assign({}, state, {timestampsVisible: action.visible});
     case SELECT_NETWORK_MESSAGE_TAB:
-      return state.set("networkMessageActiveTabId", action.id);
+      return Object.assign({}, state, {networkMessageActiveTabId: action.id});
     case SIDEBAR_TOGGLE:
-      return state.set("sidebarVisible", !state.sidebarVisible);
+      return Object.assign({}, state, {sidebarVisible: !state.sidebarVisible});
     case INITIALIZE:
-      return state.set("initialized", true);
+      return Object.assign({}, state, {initialized: true});
   }
 
   return state;
 }
 
 module.exports = {
   UiState,
   ui,
--- a/devtools/client/webconsole/new-console-output/store.js
+++ b/devtools/client/webconsole/new-console-output/store.js
@@ -51,17 +51,17 @@ function configureStore(hud, options = {
       warn: Services.prefs.getBoolPref(PREFS.FILTER.WARN),
       info: Services.prefs.getBoolPref(PREFS.FILTER.INFO),
       debug: Services.prefs.getBoolPref(PREFS.FILTER.DEBUG),
       log: Services.prefs.getBoolPref(PREFS.FILTER.LOG),
       css: Services.prefs.getBoolPref(PREFS.FILTER.CSS),
       net: Services.prefs.getBoolPref(PREFS.FILTER.NET),
       netxhr: Services.prefs.getBoolPref(PREFS.FILTER.NETXHR),
     }),
-    ui: new UiState({
+    ui: UiState({
       filterBarVisible: Services.prefs.getBoolPref(PREFS.UI.FILTER_BAR),
       networkMessageActiveTabId: "headers",
       persistLogs: Services.prefs.getBoolPref(PREFS.UI.PERSIST),
     })
   };
 
   return createStore(
     createRootReducer(),