fix(web): make the finished-processing refresh effect actually fire (#1188)

This commit is contained in:
Abhay Singh 2026-07-11 07:45:02 +05:30 committed by GitHub
parent 72ab99a77b
commit b49903a493
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,12 +37,20 @@ export function useProcessingDocuments() {
staleTime: 0,
})
const docs =
(
data as
| { documents?: Array<{ id?: string | null; status?: string | null }> }
| undefined
)?.documents ?? []
// Memoized on `data` (kept referentially stable between polls by React
// Query's structural sharing) so `processingMap` only changes identity
// when the poll payload actually changes — the effect below depends on it.
const docs = useMemo(
() =>
(
data as
| {
documents?: Array<{ id?: string | null; status?: string | null }>
}
| undefined
)?.documents ?? [],
[data],
)
const processingMap = useMemo(() => {
const map = new Map<string, string>()
@ -52,7 +60,6 @@ export function useProcessingDocuments() {
}
}
return map
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [docs])
// Detect docs that just finished (present in previous poll, absent now).
@ -80,8 +87,10 @@ export function useProcessingDocuments() {
clearTimeout(t1)
clearTimeout(t2)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [processingMap.keys, queryClient.refetchQueries])
// `processingMap` (not `processingMap.keys` — that's the shared
// Map.prototype method, identical for every map, so the effect would
// never re-run and finished docs would never trigger a refresh).
}, [processingMap, queryClient])
return processingMap
}