From daf7f35196171b9777123f6a99fb322486f72f19 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sat, 22 Feb 2025 13:23:33 +0100 Subject: [PATCH] feat: scroll to top on tab home press --- components/settings/HomeIndex.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/settings/HomeIndex.tsx b/components/settings/HomeIndex.tsx index 565d1d58..9c0919f5 100644 --- a/components/settings/HomeIndex.tsx +++ b/components/settings/HomeIndex.tsx @@ -25,7 +25,12 @@ import { } from "@jellyfin/sdk/lib/utils/api"; import NetInfo from "@react-native-community/netinfo"; import { QueryFunction, useQuery } from "@tanstack/react-query"; -import { useNavigation, useRouter } from "expo-router"; +import { + useNavigation, + usePathname, + useRouter, + useSegments, +} from "expo-router"; import { useAtomValue } from "jotai"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -107,15 +112,17 @@ export const HomeIndex = () => { ); }, []); + const segments = useSegments(); useEffect(() => { const unsubscribe = eventBus.on("scrollToTop", () => { - scrollViewRef.current?.scrollTo({ y: -152, animated: true }); + if (segments[2] === "(home)") + scrollViewRef.current?.scrollTo({ y: -152, animated: true }); }); return () => { unsubscribe(); }; - }, []); + }, [segments]); const checkConnection = useCallback(async () => { setLoadingRetry(true);