tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

messages.js (2176B)


      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 loader.lazyRequireGetter(
      7  this,
      8  ["getParentWarningGroupMessageId", "getWarningGroupType"],
      9  "resource://devtools/client/webconsole/utils/messages.js",
     10  true
     11 );
     12 
     13 function getMutableMessagesById(state) {
     14  return state.messages.mutableMessagesById;
     15 }
     16 
     17 function getMessage(state, id) {
     18  return getMutableMessagesById(state).get(id);
     19 }
     20 
     21 function getAllMessagesUiById(state) {
     22  return state.messages.messagesUiById;
     23 }
     24 
     25 function getAllDisabledMessagesById(state) {
     26  return state.messages.disabledMessagesById;
     27 }
     28 
     29 function getAllCssMessagesMatchingElements(state) {
     30  return state.messages.cssMessagesMatchingElements;
     31 }
     32 
     33 function getAllGroupsById(state) {
     34  return state.messages.groupsById;
     35 }
     36 
     37 function getCurrentGroup(state) {
     38  return state.messages.currentGroup;
     39 }
     40 
     41 function getVisibleMessages(state) {
     42  return state.messages.visibleMessages;
     43 }
     44 
     45 function getFilteredMessagesCount(state) {
     46  return state.messages.filteredMessagesCount;
     47 }
     48 
     49 function getAllRepeatById(state) {
     50  return state.messages.repeatById;
     51 }
     52 
     53 function getAllNetworkMessagesUpdateById(state) {
     54  return state.messages.networkMessagesUpdateById;
     55 }
     56 
     57 function getGroupsById(state) {
     58  return state.messages.groupsById;
     59 }
     60 
     61 function getAllWarningGroupsById(state) {
     62  return state.messages.warningGroupsById;
     63 }
     64 
     65 function getLastMessageId(state) {
     66  return state.messages.lastMessageId;
     67 }
     68 
     69 function isMessageInWarningGroup(message, visibleMessages = []) {
     70  if (!getWarningGroupType(message)) {
     71    return false;
     72  }
     73 
     74  return visibleMessages.includes(getParentWarningGroupMessageId(message));
     75 }
     76 
     77 module.exports = {
     78  getAllGroupsById,
     79  getAllWarningGroupsById,
     80  getMutableMessagesById,
     81  getAllCssMessagesMatchingElements,
     82  getAllMessagesUiById,
     83  getAllDisabledMessagesById,
     84  getAllNetworkMessagesUpdateById,
     85  getAllRepeatById,
     86  getCurrentGroup,
     87  getFilteredMessagesCount,
     88  getGroupsById,
     89  getLastMessageId,
     90  getMessage,
     91  getVisibleMessages,
     92  isMessageInWarningGroup,
     93 };