mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-10 22:32:22 +00:00
Compare commits
2 Commits
renovate/r
...
fix/refres
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a16d73688f | ||
|
|
ac0d3fcb86 |
4
bun.lock
4
bun.lock
@@ -80,7 +80,7 @@
|
||||
"react-native-reanimated-carousel": "4.0.3",
|
||||
"react-native-safe-area-context": "~5.6.0",
|
||||
"react-native-screens": "~4.18.0",
|
||||
"react-native-svg": "15.15.2",
|
||||
"react-native-svg": "15.12.1",
|
||||
"react-native-text-ticker": "^1.15.0",
|
||||
"react-native-track-player": "github:lovegaoshi/react-native-track-player#APM",
|
||||
"react-native-udp": "^4.1.7",
|
||||
@@ -1690,7 +1690,7 @@
|
||||
|
||||
"react-native-screens": ["react-native-screens@4.18.0", "", { "dependencies": { "react-freeze": "^1.0.0", "warn-once": "^0.1.0" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-mRTLWL7Uc1p/RFNveEIIrhP22oxHduC2ZnLr/2iHwBeYpGXR0rJZ7Bgc0ktxQSHRjWTPT70qc/7yd4r9960PBQ=="],
|
||||
|
||||
"react-native-svg": ["react-native-svg@15.15.2", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-lpaSwA2i+eLvcEdDZyGgMEInQW99K06zjJqfMFblE0yxI0SCN5E4x6in46f0IYi6i3w2t2aaq3oOnyYBe+bo4w=="],
|
||||
"react-native-svg": ["react-native-svg@15.12.1", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-vCuZJDf8a5aNC2dlMovEv4Z0jjEUET53lm/iILFnFewa15b4atjVxU6Wirm6O9y6dEsdjDZVD7Q3QM4T1wlI8g=="],
|
||||
|
||||
"react-native-tab-view": ["react-native-tab-view@4.2.0", "", { "dependencies": { "use-latest-callback": "^0.2.4" }, "peerDependencies": { "react": ">= 18.2.0", "react-native": "*", "react-native-pager-view": ">= 6.0.0" } }, "sha512-TUbh7Yr0tE/99t1pJQLbQ+4/Px67xkT7/r3AhfV+93Q3WoUira0Lx7yuKUP2C118doqxub8NCLERwcqsHr29nQ=="],
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import { MediaListSection } from "@/components/medialists/MediaListSection";
|
||||
import { Colors } from "@/constants/Colors";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { useNetworkStatus } from "@/hooks/useNetworkStatus";
|
||||
import { useRefetchHomeOnForeground } from "@/hooks/useRefetchHomeOnForeground";
|
||||
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
|
||||
import { useDownload } from "@/providers/DownloadProvider";
|
||||
import { useIntroSheet } from "@/providers/IntroSheetProvider";
|
||||
@@ -107,6 +108,9 @@ export const Home = () => {
|
||||
prevIsConnected.current = isConnected;
|
||||
}, [isConnected, invalidateCache]);
|
||||
|
||||
// Refresh home data on mount (cold start) and when app returns to foreground
|
||||
useRefetchHomeOnForeground();
|
||||
|
||||
const hasDownloads = useMemo(() => {
|
||||
if (Platform.isTV) return false;
|
||||
return downloadedItems.length > 0;
|
||||
|
||||
@@ -37,6 +37,7 @@ import { MediaListSection } from "@/components/medialists/MediaListSection";
|
||||
import { Colors } from "@/constants/Colors";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { useNetworkStatus } from "@/hooks/useNetworkStatus";
|
||||
import { useRefetchHomeOnForeground } from "@/hooks/useRefetchHomeOnForeground";
|
||||
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
|
||||
import { useDownload } from "@/providers/DownloadProvider";
|
||||
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
||||
@@ -67,8 +68,7 @@ export const HomeWithCarousel = () => {
|
||||
const api = useAtomValue(apiAtom);
|
||||
const user = useAtomValue(userAtom);
|
||||
const insets = useSafeAreaInsets();
|
||||
const [_loading, setLoading] = useState(false);
|
||||
const { settings, refreshStreamyfinPluginSettings } = useSettings();
|
||||
const { settings } = useSettings();
|
||||
const headerOverlayOffset = Platform.isTV ? 0 : 60;
|
||||
const navigation = useNavigation();
|
||||
const animatedScrollRef = useAnimatedRef<Animated.ScrollView>();
|
||||
@@ -91,6 +91,9 @@ export const HomeWithCarousel = () => {
|
||||
prevIsConnected.current = isConnected;
|
||||
}, [isConnected, invalidateCache]);
|
||||
|
||||
// Refresh home data on mount (cold start) and when app returns to foreground
|
||||
useRefetchHomeOnForeground();
|
||||
|
||||
const hasDownloads = useMemo(() => {
|
||||
if (Platform.isTV) return false;
|
||||
return downloadedItems.length > 0;
|
||||
@@ -178,13 +181,6 @@ export const HomeWithCarousel = () => {
|
||||
);
|
||||
}, [userViews]);
|
||||
|
||||
const _refetch = async () => {
|
||||
setLoading(true);
|
||||
await refreshStreamyfinPluginSettings();
|
||||
await invalidateCache();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const createCollectionConfig = useCallback(
|
||||
(
|
||||
title: string,
|
||||
|
||||
@@ -37,7 +37,18 @@ export const ItemPeopleSections: React.FC<Props> = ({ item, ...props }) => {
|
||||
return { ...item, People: people } as BaseItemDto;
|
||||
}, [item, people]);
|
||||
|
||||
const topPeople = useMemo(() => people.slice(0, 3), [people]);
|
||||
const topPeople = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
const unique: BaseItemPerson[] = [];
|
||||
for (const person of people) {
|
||||
if (person.Id && !seen.has(person.Id)) {
|
||||
seen.add(person.Id);
|
||||
unique.push(person);
|
||||
}
|
||||
if (unique.length >= 3) break;
|
||||
}
|
||||
return unique;
|
||||
}, [people]);
|
||||
|
||||
const renderActorSection = useCallback(
|
||||
(person: BaseItemPerson, idx: number, total: number) => {
|
||||
|
||||
32
hooks/useRefetchHomeOnForeground.ts
Normal file
32
hooks/useRefetchHomeOnForeground.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
import { AppState } from "react-native";
|
||||
|
||||
/**
|
||||
* Refetches active home queries on mount (cold start) and whenever
|
||||
* the app returns to the foreground from background.
|
||||
*/
|
||||
export function useRefetchHomeOnForeground() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
useEffect(() => {
|
||||
// On mount (cold start), use cancelRefetch: false so we don't cancel
|
||||
// an in-flight initial fetch that React Query already started.
|
||||
queryClient.refetchQueries(
|
||||
{ queryKey: ["home"], type: "active" },
|
||||
{ cancelRefetch: false },
|
||||
);
|
||||
|
||||
const subscription = AppState.addEventListener("change", (state) => {
|
||||
if (state === "active") {
|
||||
// On foreground return, force a fresh refetch
|
||||
queryClient.refetchQueries(
|
||||
{ queryKey: ["home"], type: "active" },
|
||||
{ cancelRefetch: true },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return () => subscription.remove();
|
||||
}, [queryClient]);
|
||||
}
|
||||
@@ -100,7 +100,7 @@
|
||||
"react-native-reanimated-carousel": "4.0.3",
|
||||
"react-native-safe-area-context": "~5.6.0",
|
||||
"react-native-screens": "~4.18.0",
|
||||
"react-native-svg": "15.15.2",
|
||||
"react-native-svg": "15.12.1",
|
||||
"react-native-text-ticker": "^1.15.0",
|
||||
"react-native-track-player": "github:lovegaoshi/react-native-track-player#APM",
|
||||
"react-native-udp": "^4.1.7",
|
||||
|
||||
Reference in New Issue
Block a user