Bug 1307884 - Remove prune function; r=bgrins draft
authorJan Odvarko <odvarko@gmail.com>
Mon, 22 May 2017 19:59:20 +0200
changeset 582480 31e80ce3ea2dc3734a01a83e8871607d79fa3020
parent 582479 8daa22c4645c15a04af636a02315a9246211dcb0
child 582481 1cbcc672d29b0350645f4decb18fe8c55385a331
push id60109
push userjodvarko@mozilla.com
push dateMon, 22 May 2017 18:06:18 +0000
reviewersbgrins
bugs1307884
milestone55.0a1
Bug 1307884 - Remove prune function; r=bgrins MozReview-Commit-ID: B6VGrJOe0sk
devtools/client/webconsole/new-console-output/selectors/messages.js
--- a/devtools/client/webconsole/new-console-output/selectors/messages.js
+++ b/devtools/client/webconsole/new-console-output/selectors/messages.js
@@ -2,49 +2,44 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* 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 { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
 const { getAllFilters } = require("devtools/client/webconsole/new-console-output/selectors/filters");
-const { getLogLimit } = require("devtools/client/webconsole/new-console-output/selectors/prefs");
 const { getGripPreviewItems } = require("devtools/client/shared/components/reps/reps");
 const { getSourceNames } = require("devtools/client/shared/source-utils");
 const {
   MESSAGE_TYPE,
   MESSAGE_SOURCE
 } = require("devtools/client/webconsole/new-console-output/constants");
 
 function getAllMessages(state) {
   let messages = getAllMessagesById(state);
-  let logLimit = getLogLimit(state);
   let filters = getAllFilters(state);
 
   let groups = getAllGroupsById(state);
   let messagesUI = getAllMessagesUiById(state);
 
-  return prune(
-    messages.filter(message => {
-      return (
-        isInOpenedGroup(message, groups, messagesUI)
-        && (
-          isUnfilterable(message)
-          || (
-            matchLevelFilters(message, filters)
-            && matchCssFilters(message, filters)
-            && matchNetworkFilters(message, filters)
-            && matchSearchFilters(message, filters)
-          )
+  return messages.filter(message => {
+    return (
+      isInOpenedGroup(message, groups, messagesUI)
+      && (
+        isUnfilterable(message)
+        || (
+          matchLevelFilters(message, filters)
+          && matchCssFilters(message, filters)
+          && matchNetworkFilters(message, filters)
+          && matchSearchFilters(message, filters)
         )
-      );
-    }),
-    logLimit
-  );
+      )
+    );
+  });
 }
 
 function getAllMessagesById(state) {
   return state.messages.messagesById;
 }
 
 function getAllMessagesUiById(state) {
   return state.messages.messagesUiById;
@@ -233,33 +228,13 @@ function getAllProps(grips) {
   result = result.filter(grip =>
     typeof grip != "object" &&
     typeof grip != "undefined"
   );
 
   return [...new Set(result)];
 }
 
-function prune(messages, logLimit) {
-  let messageCount = messages.count();
-  if (messageCount > logLimit) {
-    // If the second non-pruned message is in a group,
-    // we want to return the group as the first non-pruned message.
-    let firstIndex = messages.size - logLimit;
-    let groupId = messages.get(firstIndex + 1).groupId;
-
-    if (groupId) {
-      return messages.splice(0, firstIndex + 1)
-        .unshift(
-          messages.findLast((message) => message.id === groupId)
-        );
-    }
-    return messages.splice(0, firstIndex);
-  }
-
-  return messages;
-}
-
 exports.getAllMessages = getAllMessages;
 exports.getAllMessagesUiById = getAllMessagesUiById;
 exports.getAllMessagesTableDataById = getAllMessagesTableDataById;
 exports.getAllGroupsById = getAllGroupsById;
 exports.getCurrentGroup = getCurrentGroup;