feat(tv): add 60s background refresh for idle screens

This commit is contained in:
Fredrik Burmester
2026-01-24 10:48:42 +01:00
parent a852e2e769
commit c215fda973
7 changed files with 19 additions and 6 deletions

View File

@@ -62,6 +62,7 @@ const page: React.FC = () => {
});
},
staleTime: isOffline ? Infinity : 60 * 1000,
refetchInterval: !isOffline && Platform.isTV ? 60 * 1000 : undefined,
enabled: isOffline || (!!api && !!user?.Id),
});
@@ -117,7 +118,8 @@ const page: React.FC = () => {
(a.ParentIndexNumber ?? 0) - (b.ParentIndexNumber ?? 0) ||
(a.IndexNumber ?? 0) - (b.IndexNumber ?? 0),
),
staleTime: isOffline ? Infinity : 60,
staleTime: isOffline ? Infinity : 60 * 1000,
refetchInterval: !isOffline && Platform.isTV ? 60 * 1000 : undefined,
enabled: isOffline || (!!api && !!user?.Id),
});

View File

@@ -201,6 +201,7 @@ export const Home = () => {
},
enabled: !!api && !!user?.Id,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
});
const userViews = useMemo(

View File

@@ -211,6 +211,7 @@ export const InfiniteScrollingCollectionList: React.FC<Props> = ({
},
initialPageParam: 0,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
refetchOnWindowFocus: false,
refetchOnReconnect: true,
enabled,

View File

@@ -108,7 +108,8 @@ const WatchlistSection: React.FC<WatchlistSectionProps> = ({
Boolean(settings?.streamyStatsServerUrl) &&
Boolean(api?.accessToken) &&
Boolean(user?.Id),
staleTime: 5 * 60 * 1000,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
refetchOnWindowFocus: false,
});
@@ -277,7 +278,8 @@ export const StreamystatsPromotedWatchlists: React.FC<
Boolean(api?.accessToken) &&
Boolean(jellyfinServerId) &&
Boolean(user?.Id),
staleTime: 5 * 60 * 1000,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
refetchOnWindowFocus: false,
});

View File

@@ -133,7 +133,8 @@ export const StreamystatsRecommendations: React.FC<Props> = ({
Boolean(api?.accessToken) &&
Boolean(jellyfinServerId) &&
Boolean(user?.Id),
staleTime: 5 * 60 * 1000,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
refetchOnWindowFocus: false,
});
@@ -165,7 +166,8 @@ export const StreamystatsRecommendations: React.FC<Props> = ({
},
enabled:
Boolean(recommendationIds?.length) && Boolean(api) && Boolean(user?.Id),
staleTime: 5 * 60 * 1000,
staleTime: 60 * 1000,
refetchInterval: 60 * 1000,
refetchOnWindowFocus: false,
});

View File

@@ -293,6 +293,7 @@ export const TVSeriesPage: React.FC<TVSeriesPageProps> = ({
return response.data.Items || [];
},
staleTime: isOffline ? Infinity : 60 * 1000,
refetchInterval: !isOffline ? 60 * 1000 : undefined,
enabled: isOffline || (!!api && !!user?.Id && !!item.Id),
});
@@ -345,7 +346,8 @@ export const TVSeriesPage: React.FC<TVSeriesPageProps> = ({
});
return res.data.Items || [];
},
staleTime: isOffline ? Infinity : 0,
staleTime: isOffline ? Infinity : 60 * 1000,
refetchInterval: !isOffline ? 60 * 1000 : undefined,
enabled: isOffline
? !!item.Id && selectedSeasonNumber !== null
: !!api && !!user?.Id && !!item.Id && !!selectedSeasonId,

View File

@@ -2,6 +2,7 @@ import { ItemFields } from "@jellyfin/sdk/lib/generated-client/models";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api";
import { useQuery } from "@tanstack/react-query";
import { useAtom } from "jotai";
import { Platform } from "react-native";
import { useDownload } from "@/providers/DownloadProvider";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
@@ -49,6 +50,8 @@ export const useItemQuery = (
return response.data.Items?.[0];
},
enabled: !!itemId,
staleTime: isOffline ? Infinity : 60 * 1000,
refetchInterval: !isOffline && Platform.isTV ? 60 * 1000 : undefined,
refetchOnMount: true,
refetchOnWindowFocus: true,
refetchOnReconnect: true,