fix: cache invalidation issue

This commit is contained in:
Fredrik Burmester
2024-12-01 10:11:24 +01:00
parent 3a507b6d1b
commit 383062ac0d
6 changed files with 11 additions and 11 deletions

View File

@@ -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={
<RefreshControl refreshing={loading} onRefresh={refetch} />
}
key={"home"}
contentContainerStyle={{
paddingLeft: insets.left,
paddingRight: insets.right,

View File

@@ -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);

View File

@@ -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<VideoRef | null>(null);
const firstTime = useRef(true);
const revalidateProgressCache = useRevalidatePlaybackProgressCache();
const revalidateProgressCache = useInvalidatePlaybackProgressCache();
const [isPlaybackStopped, setIsPlaybackStopped] = useState(false);
const [showControls, _setShowControls] = useState(true);

View File

@@ -28,8 +28,10 @@ export const ScrollingCollectionList: React.FC<Props> = ({
queryKey,
...props
}) => {
// console.log(queryKey);
const { data, isLoading } = useQuery({
queryKey,
queryKey: queryKey,
queryFn,
staleTime: 0,
refetchOnMount: true,

View File

@@ -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 () => {

View File

@@ -572,11 +572,10 @@ function useDownloadProvider() {
export function DownloadProvider({ children }: { children: React.ReactNode }) {
const downloadProviderValue = useDownloadProvider();
const queryClient = new QueryClient();
return (
<DownloadContext.Provider value={downloadProviderValue}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
{children}
</DownloadContext.Provider>
);
}