Page MenuHomePhorge

D14811.1768459159.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D14811.1768459159.diff

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<LogType>) => {
+ (title: string, message: string, types: $ReadOnlySet<LogType>) => {
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<DebugLog>,
+logsFilter: $ReadOnlySet<LogType>,
+ +errorLogsCount: number,
+addLog: (
title: string,
message: string,
@@ -41,6 +42,7 @@
React.createContext<DebugLogsContextType>({
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 = (
- <div className={css.settingsBadge}>{debugLogs.logs.length}</div>
- );
+ if (staffCanSee && errorLogsCount > 0) {
+ logsBadge = <div className={css.settingsBadge}>{errorLogsCount}</div>;
}
return (

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 15, 6:39 AM (8 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5936544
Default Alt Text
D14811.1768459159.diff (3 KB)

Event Timeline