This commit is contained in:
chriscrosstalk 2026-07-13 18:13:06 -05:00 committed by GitHub
commit 55c3984371
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -175,6 +175,26 @@ export default function ZimRemoteExplorer() {
}, [data, downloads, localFiles])
const hasMore = useMemo(() => data?.pages[data.pages.length - 1]?.has_more || false, [data])
// When a ZIM download drops off the polled downloads list it has completed (or been
// cancelled). The installed-files query (refetchOnWindowFocus is off) won't otherwise
// refresh, so a just-installed ZIM stays absent from `localFiles` and reappears in the
// accumulated remote pages as a ghost entry. Refresh it so the item is pruned.
const prevDownloadKeysRef = useRef<Set<string>>(new Set())
useEffect(() => {
const currentKeys = new Set((downloads ?? []).map((d) => d.jobId))
let anyRemoved = false
for (const key of prevDownloadKeysRef.current) {
if (!currentKeys.has(key)) {
anyRemoved = true
break
}
}
prevDownloadKeysRef.current = currentKeys
if (anyRemoved) {
queryClient.invalidateQueries({ queryKey: [ZIM_FILES_KEY] })
}
}, [downloads, queryClient])
const fetchOnBottomReached = useCallback(
(parentRef?: HTMLDivElement | null) => {
if (parentRef) {