Bug 1419367 - NetMonitor: Stop using ImmutableJS in sort reducer. r=Honza
authorabhinav <abhinav.koppula@gmail.com>
Wed, 29 Nov 2017 09:17:04 +0530
changeset 706810 2cf30748e1c1073157b6ed0e81de20d2f5688d49
parent 706809 9594dc22ebdd2722af747cec76fec3fe8374c206
child 706811 c32c3cd8c898fe0bf44775680adcab530aaf2eed
push id91936
push userbmo:emilio@crisal.io
push dateMon, 04 Dec 2017 10:24:39 +0000
reviewersHonza
bugs1419367
milestone59.0a1
Bug 1419367 - NetMonitor: Stop using ImmutableJS in sort reducer. r=Honza MozReview-Commit-ID: BXc9Y350MC
devtools/client/netmonitor/src/reducers/sort.js
--- a/devtools/client/netmonitor/src/reducers/sort.js
+++ b/devtools/client/netmonitor/src/reducers/sort.js
@@ -1,34 +1,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const I = require("devtools/client/shared/vendor/immutable");
 const { SORT_BY } = require("../constants");
 
-const Sort = I.Record({
-  // null means: sort by "waterfall", but don't highlight the table header
-  type: null,
-  ascending: true,
-});
+function Sort() {
+  return {
+    // null means: sort by "waterfall", but don't highlight the table header
+    type: null,
+    ascending: true,
+  };
+}
 
 function sortReducer(state = new Sort(), action) {
   switch (action.type) {
     case SORT_BY: {
-      return state.withMutations(st => {
-        if (action.sortType == st.type) {
-          st.ascending = !st.ascending;
-        } else {
-          st.type = action.sortType;
-          st.ascending = true;
-        }
-      });
+      state = { ...state };
+      if (action.sortType == state.type) {
+        state.ascending = !state.ascending;
+      } else {
+        state.type = action.sortType;
+        state.ascending = true;
+      }
+      return state;
     }
     default:
       return state;
   }
 }
 
 module.exports = {
   Sort,