Merge 91428bb08d into 6a4f02dd46
This commit is contained in:
commit
55c3984371
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue