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, defaultLogsFilter, 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: $ReadOnlySet) => { + (title: string, message: string, types: $ReadOnlySet) => { console.log(`${title}: ${message}`); if (!isCurrentUserStaff && !isDev) { @@ -35,7 +36,7 @@ title, message, timestamp: Date.now(), - logTypes, + logTypes: types, }, ]); }, @@ -72,15 +73,21 @@ [], ); + const errorLogsCount = React.useMemo( + () => logs.filter(log => log.logTypes.has(logTypes.ERROR)).length, + [logs], + ); + const contextValue = React.useMemo( () => ({ logsFilter, logs: filteredLogs, + errorLogsCount, addLog, clearLogs, setFilter, }), - [addLog, clearLogs, filteredLogs, logsFilter, setFilter], + [addLog, clearLogs, errorLogsCount, 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 @@ -28,6 +28,7 @@ export type DebugLogsContextType = { +logs: $ReadOnlyArray, +logsFilter: $ReadOnlySet, + +errorLogsCount: number, +addLog: ( title: string, message: string, @@ -41,6 +42,7 @@ React.createContext({ logsFilter: defaultLogsFilter, logs: [], + errorLogsCount: 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 { errorLogsCount } = useDebugLogs(); + const profileBadge = staffCanSee ? errorLogsCount : 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 { errorLogsCount } = useDebugLogs(); let logsBadge = null; - if (staffCanSee && debugLogs.logs.length > 0) { - logsBadge = ( -
{debugLogs.logs.length}
- ); + if (staffCanSee && errorLogsCount > 0) { + logsBadge =
{errorLogsCount}
; } return (