diff --git a/lib/components/debug-logs-context-provider.react.js b/lib/components/debug-logs-context-provider.react.js --- a/lib/components/debug-logs-context-provider.react.js +++ b/lib/components/debug-logs-context-provider.react.js @@ -7,6 +7,7 @@ DebugLogsContext, defaultLosFilter, type LogType, + logTypes, } from './debug-logs-context.js'; import { useIsCurrentUserStaff } from '../shared/staff-utils.js'; import { isDev } from '../utils/dev-utils.js'; @@ -22,7 +23,7 @@ const isCurrentUserStaff = useIsCurrentUserStaff(); const addLog = React.useCallback( - (title: string, message: string, logTypes: $ReadOnlyArray) => { + (title: string, message: string, types: $ReadOnlyArray) => { console.log(`${title}: ${message}`); if (!isCurrentUserStaff && !isDev) { @@ -35,7 +36,7 @@ title, message, timestamp: Date.now(), - logTypes, + logTypes: types, }, ]); }, @@ -67,15 +68,21 @@ [], ); + const errorLogsNumber = React.useMemo( + () => logs.filter(log => log.logTypes.includes(logTypes.ERROR)).length, + [logs], + ); + const contextValue = React.useMemo( () => ({ logsFilter, logs: filteredLogs, + errorLogsNumber, addLog, clearLogs, setFilter, }), - [addLog, clearLogs, filteredLogs, logsFilter, setFilter], + [addLog, clearLogs, errorLogsNumber, filteredLogs, logsFilter, setFilter], ); return ( diff --git a/lib/components/debug-logs-context.js b/lib/components/debug-logs-context.js --- a/lib/components/debug-logs-context.js +++ b/lib/components/debug-logs-context.js @@ -30,6 +30,7 @@ export type DebugLogsContextType = { +logs: $ReadOnlyArray, +logsFilter: $ReadOnlyMap, + +errorLogsNumber: number, +addLog: ( title: string, message: string, @@ -43,6 +44,7 @@ React.createContext({ logsFilter: defaultLosFilter, logs: [], + errorLogsNumber: 0, addLog: () => {}, clearLogs: () => {}, setFilter: () => {}, diff --git a/native/navigation/tab-navigator.react.js b/native/navigation/tab-navigator.react.js --- a/native/navigation/tab-navigator.react.js +++ b/native/navigation/tab-navigator.react.js @@ -155,8 +155,8 @@ const chatBadge = useSelector(unreadCount); const staffCanSee = useStaffCanSee(); - const debugLogs = useDebugLogs(); - const profileBadge = staffCanSee ? debugLogs.logs.length : 0; + const { errorLogsNumber } = useDebugLogs(); + const profileBadge = staffCanSee ? errorLogsNumber : 0; const isCalendarEnabled = useSelector(state => state.enabledApps.calendar); diff --git a/web/sidebar/community-picker.react.js b/web/sidebar/community-picker.react.js --- a/web/sidebar/community-picker.react.js +++ b/web/sidebar/community-picker.react.js @@ -98,12 +98,10 @@ } const staffCanSee = useStaffCanSee(); - const debugLogs = useDebugLogs(); + const { errorLogsNumber } = useDebugLogs(); let logsBadge = null; - if (staffCanSee && debugLogs.logs.length > 0) { - logsBadge = ( -
{debugLogs.logs.length}
- ); + if (staffCanSee && errorLogsNumber > 0) { + logsBadge =
{errorLogsNumber}
; } return (