From 83b20c88f030b802711d20d2310012042eb88bec Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 9 Dec 2025 19:42:00 -0600 Subject: [PATCH] Don't nag git updates so much --- src/hooks/useGitFetch.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hooks/useGitFetch.ts b/src/hooks/useGitFetch.ts index 596097fb..903b963a 100644 --- a/src/hooks/useGitFetch.ts +++ b/src/hooks/useGitFetch.ts @@ -34,6 +34,7 @@ export function useGitFetch(projectId: string | null) { const previousStateRef = useRef<{ defaultBranchOid: string | null; currentBranchOid: string | null; + dataUpdatedAt: number; } | null>(null); const query = useQuery({ @@ -300,16 +301,17 @@ export function useGitFetch(projectId: string | null) { // Show toast notifications when changes are detected useEffect(() => { - if (!query.data || !query.isSuccess) { + if (!query.data || !query.isSuccess || query.dataUpdatedAt === undefined) { return; } const currentState = { defaultBranchOid: query.data.defaultBranchOid, currentBranchOid: query.data.currentBranchOid, + dataUpdatedAt: query.dataUpdatedAt, }; - // Skip on first load + // Initialize on first load or after component remount if (previousStateRef.current === null) { previousStateRef.current = currentState; return; @@ -317,6 +319,12 @@ export function useGitFetch(projectId: string | null) { const prevState = previousStateRef.current; + // Skip if this is the same data we've already seen (same dataUpdatedAt timestamp) + // This prevents showing toasts when navigating back to a project with cached data + if (prevState.dataUpdatedAt === currentState.dataUpdatedAt) { + return; + } + // Detect default branch changes const defaultBranchChanged = prevState.defaultBranchOid !== null && @@ -356,7 +364,7 @@ export function useGitFetch(projectId: string | null) { // Update previous state previousStateRef.current = currentState; - }, [query.data, query.isSuccess, toast, queryClient, projectId]); + }, [query.data, query.isSuccess, query.dataUpdatedAt, toast, queryClient, projectId]); return query; }