From 09c6ad47d5dbb537db75547114170c879f306ac1 Mon Sep 17 00:00:00 2001 From: Alex Kim Date: Sat, 12 Oct 2024 19:07:16 +1100 Subject: [PATCH 1/2] Update visual playback when exiting video --- app/(auth)/play-video.tsx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/(auth)/play-video.tsx b/app/(auth)/play-video.tsx index cce91dcc..89502154 100644 --- a/app/(auth)/play-video.tsx +++ b/app/(auth)/play-video.tsx @@ -15,6 +15,7 @@ import { getAuthHeaders } from "@/utils/jellyfin/jellyfin"; import { secondsToTicks } from "@/utils/secondsToTicks"; import { Api } from "@jellyfin/sdk"; import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api"; +import { useQueryClient } from "@tanstack/react-query"; import * as Haptics from "expo-haptics"; import { useFocusEffect } from "expo-router"; import { useAtomValue } from "jotai"; @@ -105,7 +106,36 @@ export default function page() { videoRef.current?.pause(); }, [videoRef]); + const queryClient = useQueryClient(); + const stop = useCallback(() => { + queryClient.invalidateQueries({ + queryKey: ["item", playSettings?.item?.Id], + }); + queryClient.invalidateQueries({ + queryKey: ["resumeItems"], + }); + queryClient.invalidateQueries({ + queryKey: ["continueWatching"], + }); + queryClient.invalidateQueries({ + queryKey: ["nextUp-all"], + }); + queryClient.invalidateQueries({ + queryKey: ["nextUp"], + }); + queryClient.invalidateQueries({ + queryKey: ["episodes"], + }); + queryClient.invalidateQueries({ + queryKey: ["seasons"], + }); + queryClient.invalidateQueries({ + queryKey: ["nextUp-all"], + }); + queryClient.invalidateQueries({ + queryKey: ["home"], + }); setIsPlaybackStopped(true); videoRef.current?.pause(); reportPlaybackStopped(); From af9f722b53fc7f30019d68ec39e813ee157760ca Mon Sep 17 00:00:00 2001 From: Alex Kim Date: Mon, 14 Oct 2024 19:24:13 +1100 Subject: [PATCH 2/2] Removed duplicate Invalidate queries for next-up --- app/(auth)/play-video.tsx | 5 +---- components/PlayedStatus.tsx | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/(auth)/play-video.tsx b/app/(auth)/play-video.tsx index 89502154..48c1dfac 100644 --- a/app/(auth)/play-video.tsx +++ b/app/(auth)/play-video.tsx @@ -130,16 +130,13 @@ export default function page() { queryClient.invalidateQueries({ queryKey: ["seasons"], }); - queryClient.invalidateQueries({ - queryKey: ["nextUp-all"], - }); queryClient.invalidateQueries({ queryKey: ["home"], }); setIsPlaybackStopped(true); videoRef.current?.pause(); reportPlaybackStopped(); - }, [videoRef]); + }, [queryClient, videoRef]); const reportPlaybackStopped = async () => { await getPlaystateApi(api).onPlaybackStopped({ diff --git a/components/PlayedStatus.tsx b/components/PlayedStatus.tsx index 82e9057d..0d483858 100644 --- a/components/PlayedStatus.tsx +++ b/components/PlayedStatus.tsx @@ -41,9 +41,6 @@ export const PlayedStatus: React.FC = ({ item, ...props }) => { queryClient.invalidateQueries({ queryKey: ["seasons"], }); - queryClient.invalidateQueries({ - queryKey: ["nextUp-all"], - }); queryClient.invalidateQueries({ queryKey: ["home"], });