diff --git a/app/(auth)/(tabs)/(home)/index.tsx b/app/(auth)/(tabs)/(home)/index.tsx index 26e4c0e8..e9f5417d 100644 --- a/app/(auth)/(tabs)/(home)/index.tsx +++ b/app/(auth)/(tabs)/(home)/index.tsx @@ -5,6 +5,7 @@ import { ScrollingCollectionList } from "@/components/home/ScrollingCollectionLi import { Loader } from "@/components/Loader"; import { MediaListSection } from "@/components/medialists/MediaListSection"; import { Colors } from "@/constants/Colors"; +import { useRevalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useDownload } from "@/providers/DownloadProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { useSettings } from "@/utils/atoms/settings"; @@ -163,20 +164,13 @@ export default function index() { ); }, [userViews]); + const invalidateCache = useRevalidatePlaybackProgressCache(); + const refetch = useCallback(async () => { setLoading(true); - await queryClient.invalidateQueries({ - queryKey: ["home"], - type: "all", - exact: false, - }); - await queryClient.invalidateQueries({ - queryKey: ["item"], - type: "all", - exact: false, - }); + await invalidateCache(); setLoading(false); - }, [queryClient]); + }, []); const createCollectionConfig = useCallback( ( diff --git a/hooks/useRevalidatePlaybackProgressCache.ts b/hooks/useRevalidatePlaybackProgressCache.ts index 082870d9..f939502b 100644 --- a/hooks/useRevalidatePlaybackProgressCache.ts +++ b/hooks/useRevalidatePlaybackProgressCache.ts @@ -6,7 +6,7 @@ import { useQueryClient } from "@tanstack/react-query"; export function useRevalidatePlaybackProgressCache() { const queryClient = useQueryClient(); - const revalidate = () => { + const revalidate = async () => { // List of all the queries to invalidate const queriesToInvalidate = [ ["item"], @@ -20,9 +20,9 @@ export function useRevalidatePlaybackProgressCache() { ]; // Invalidate each query - queriesToInvalidate.forEach((queryKey) => { - queryClient.invalidateQueries({ queryKey }); - }); + for (const queryKey of queriesToInvalidate) { + await queryClient.invalidateQueries({ queryKey }); + } }; return revalidate;