TypeScript
perf(web): thread notifications compile with the React Compiler (#20454)
Julius Marminge68b47e71c057
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.tsindex 6fd5b6123e3..2b69c016203 100644--- a/apps/web/reactCompiledFiles.ts+++ b/apps/web/reactCompiledFiles.ts@@ -29,4 +29,5 @@ export const REACT_COMPILED_FILES = ["apps/web/src/browser/ServerBrowserSurface.tsx","apps/web/src/assets/assetUrls.ts","apps/web/src/components/ui/toggle-group.tsx",+ "apps/web/src/components/ThreadNotificationCoordinator.tsx",] as const;diff --git a/apps/web/src/components/ThreadNotificationCoordinator.tsx b/apps/web/src/components/ThreadNotificationCoordinator.tsxindex 1b013904e82..fab97abeeef 100644--- a/apps/web/src/components/ThreadNotificationCoordinator.tsx+++ b/apps/web/src/components/ThreadNotificationCoordinator.tsx@@ -13,7 +13,7 @@ import {MessageCircleQuestionIcon,ShieldQuestionIcon,} from "lucide-react";-import { useCallback, useEffect, useRef } from "react";+import { useEffect, useRef } from "react";import { getClientSettings, useClientSettings } from "../hooks/useSettings";import { useEnvironmentIds } from "../state/environments";@@ -37,18 +37,18 @@ export function ThreadNotificationCoordinator() {const pending = useRef(new Map<string, { environmentId: EnvironmentId; notification: Notification }>(),);- const onNotification = useCallback((environmentId: EnvironmentId, notification: Notification) => {+ const onNotification = (environmentId: EnvironmentId, notification: Notification) => {pending.current.get(notification.tag)?.notification.close();pending.current.set(notification.tag, { environmentId, notification });setNotificationBadge(pending.current.size);- }, []);+ };useEffect(() => {const activeIds = new Set(environmentIds);const count = pending.current.size;- for (const [tag, { environmentId, notification }] of pending.current) {- if (activeIds.has(environmentId)) continue;- notification.close();+ for (const [tag, entry] of pending.current) {+ if (activeIds.has(entry.environmentId)) continue;+ entry.notification.close();pending.current.delete(tag);}if (count !== pending.current.size) setNotificationBadge(pending.current.size);