Address Greptile review on UI polish PR

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-23 17:16:10 -05:00
parent c3f4e18a5e
commit 6960ab1106
3 changed files with 51 additions and 19 deletions

View file

@ -664,6 +664,7 @@ export function LiveUpdatesProvider({ children }: { children: ReactNode }) {
const { pushToast } = useToast();
const location = useLocation();
const gateRef = useRef<ToastGate>({ cooldownHits: new Map(), suppressUntil: 0 });
const pathnameRef = useRef(location.pathname);
const { data: session } = useQuery({
queryKey: queryKeys.auth.session,
queryFn: () => authApi.getSession(),
@ -671,6 +672,10 @@ export function LiveUpdatesProvider({ children }: { children: ReactNode }) {
});
const currentUserId = session?.user?.id ?? session?.session?.userId ?? null;
useEffect(() => {
pathnameRef.current = location.pathname;
}, [location.pathname]);
useEffect(() => {
if (!selectedCompanyId) return;
@ -715,7 +720,7 @@ export function LiveUpdatesProvider({ children }: { children: ReactNode }) {
try {
const parsed = JSON.parse(raw) as LiveEvent;
handleLiveEvent(queryClient, selectedCompanyId, location.pathname, parsed, pushToast, gateRef.current, {
handleLiveEvent(queryClient, selectedCompanyId, pathnameRef.current, parsed, pushToast, gateRef.current, {
userId: currentUserId,
agentId: null,
});
@ -747,7 +752,7 @@ export function LiveUpdatesProvider({ children }: { children: ReactNode }) {
socket.close(1000, "provider_unmount");
}
};
}, [queryClient, selectedCompanyId, pushToast, currentUserId, location.pathname]);
}, [queryClient, selectedCompanyId, pushToast, currentUserId]);
return <>{children}</>;
}