From 383062ac0dcae317a6c75fcc50e58889bf71a38b Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 1 Dec 2024 10:11:24 +0100 Subject: [PATCH] fix: cache invalidation issue --- app/(auth)/(tabs)/(home)/index.tsx | 5 ++--- app/(auth)/player/direct-player.tsx | 4 ++-- app/(auth)/player/transcoding-player.tsx | 4 ++-- components/home/ScrollingCollectionList.tsx | 4 +++- hooks/useRevalidatePlaybackProgressCache.ts | 2 +- providers/DownloadProvider.tsx | 3 +-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/(auth)/(tabs)/(home)/index.tsx b/app/(auth)/(tabs)/(home)/index.tsx index c9d3bcb7..dc17b7da 100644 --- a/app/(auth)/(tabs)/(home)/index.tsx +++ b/app/(auth)/(tabs)/(home)/index.tsx @@ -5,7 +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 { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useDownload } from "@/providers/DownloadProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { useSettings } from "@/utils/atoms/settings"; @@ -165,7 +165,7 @@ export default function index() { ); }, [userViews]); - const invalidateCache = useRevalidatePlaybackProgressCache(); + const invalidateCache = useInvalidatePlaybackProgressCache(); const refetch = useCallback(async () => { setLoading(true); @@ -371,7 +371,6 @@ export default function index() { refreshControl={ } - key={"home"} contentContainerStyle={{ paddingLeft: insets.left, paddingRight: insets.right, diff --git a/app/(auth)/player/direct-player.tsx b/app/(auth)/player/direct-player.tsx index 2eb1cc20..8c829b4b 100644 --- a/app/(auth)/player/direct-player.tsx +++ b/app/(auth)/player/direct-player.tsx @@ -5,7 +5,7 @@ import { Controls } from "@/components/video-player/controls/Controls"; import { getDownloadedFileUrl } from "@/hooks/useDownloadedFileOpener"; import { useOrientation } from "@/hooks/useOrientation"; import { useOrientationSettings } from "@/hooks/useOrientationSettings"; -import { useRevalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; +import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useWebSocket } from "@/hooks/useWebsockets"; import { VlcPlayerView } from "@/modules/vlc-player"; import { @@ -51,7 +51,7 @@ export default function page() { const cacheProgress = useSharedValue(0); const { getDownloadedItem } = useDownload(); - const revalidateProgressCache = useRevalidatePlaybackProgressCache(); + const revalidateProgressCache = useInvalidatePlaybackProgressCache(); const setShowControls = useCallback((show: boolean) => { _setShowControls(show); diff --git a/app/(auth)/player/transcoding-player.tsx b/app/(auth)/player/transcoding-player.tsx index 135654e5..88810452 100644 --- a/app/(auth)/player/transcoding-player.tsx +++ b/app/(auth)/player/transcoding-player.tsx @@ -3,7 +3,7 @@ import { Loader } from "@/components/Loader"; import { Controls } from "@/components/video-player/controls/Controls"; import { useOrientation } from "@/hooks/useOrientation"; import { useOrientationSettings } from "@/hooks/useOrientationSettings"; -import { useRevalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; +import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useWebSocket } from "@/hooks/useWebsockets"; import { TrackInfo } from "@/modules/vlc-player"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; @@ -46,7 +46,7 @@ const Player = () => { const videoRef = useRef(null); const firstTime = useRef(true); - const revalidateProgressCache = useRevalidatePlaybackProgressCache(); + const revalidateProgressCache = useInvalidatePlaybackProgressCache(); const [isPlaybackStopped, setIsPlaybackStopped] = useState(false); const [showControls, _setShowControls] = useState(true); diff --git a/components/home/ScrollingCollectionList.tsx b/components/home/ScrollingCollectionList.tsx index c7b918b3..04dd6004 100644 --- a/components/home/ScrollingCollectionList.tsx +++ b/components/home/ScrollingCollectionList.tsx @@ -28,8 +28,10 @@ export const ScrollingCollectionList: React.FC = ({ queryKey, ...props }) => { + // console.log(queryKey); + const { data, isLoading } = useQuery({ - queryKey, + queryKey: queryKey, queryFn, staleTime: 0, refetchOnMount: true, diff --git a/hooks/useRevalidatePlaybackProgressCache.ts b/hooks/useRevalidatePlaybackProgressCache.ts index f939502b..9cda914d 100644 --- a/hooks/useRevalidatePlaybackProgressCache.ts +++ b/hooks/useRevalidatePlaybackProgressCache.ts @@ -3,7 +3,7 @@ import { useQueryClient } from "@tanstack/react-query"; /** * useRevalidatePlaybackProgressCache invalidates queries related to playback progress. */ -export function useRevalidatePlaybackProgressCache() { +export function useInvalidatePlaybackProgressCache() { const queryClient = useQueryClient(); const revalidate = async () => { diff --git a/providers/DownloadProvider.tsx b/providers/DownloadProvider.tsx index 94b44137..6b95dcb4 100644 --- a/providers/DownloadProvider.tsx +++ b/providers/DownloadProvider.tsx @@ -572,11 +572,10 @@ function useDownloadProvider() { export function DownloadProvider({ children }: { children: React.ReactNode }) { const downloadProviderValue = useDownloadProvider(); - const queryClient = new QueryClient(); return ( - {children} + {children} ); }