From 773eae8cb976b4a27f2749d1aca7c117b656f5b9 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 11 Jan 2026 00:16:18 +0100 Subject: [PATCH] feat(home): add see all navigation from recently added sections --- app/(auth)/(tabs)/(libraries)/[libraryId].tsx | 46 +++++++++++++------ components/home/Home.tsx | 16 +++++++ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx index e2850631..915c362f 100644 --- a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx +++ b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx @@ -50,8 +50,13 @@ import { import { useSettings } from "@/utils/atoms/settings"; const Page = () => { - const searchParams = useLocalSearchParams(); - const { libraryId } = searchParams as { libraryId: string }; + const searchParams = useLocalSearchParams() as { + libraryId: string; + sortBy?: string; + sortOrder?: string; + filterBy?: string; + }; + const { libraryId } = searchParams; const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); @@ -76,23 +81,33 @@ const Page = () => { const { t } = useTranslation(); useEffect(() => { - const sop = getSortOrderPreference(libraryId, sortOrderPreference); - if (sop) { - _setSortOrder([sop]); + // Check for URL params first (from "See All" navigation) + const urlSortBy = searchParams.sortBy as SortByOption | undefined; + const urlSortOrder = searchParams.sortOrder as SortOrderOption | undefined; + const urlFilterBy = searchParams.filterBy as FilterByOption | undefined; + + // Apply sortOrder: URL param > saved preference > default + if (urlSortOrder && Object.values(SortOrderOption).includes(urlSortOrder)) { + _setSortOrder([urlSortOrder]); } else { - _setSortOrder([SortOrderOption.Ascending]); + const sop = getSortOrderPreference(libraryId, sortOrderPreference); + _setSortOrder([sop || SortOrderOption.Ascending]); } - const obp = getSortByPreference(libraryId, sortByPreference); - if (obp) { - _setSortBy([obp]); + + // Apply sortBy: URL param > saved preference > default + if (urlSortBy && Object.values(SortByOption).includes(urlSortBy)) { + _setSortBy([urlSortBy]); } else { - _setSortBy([SortByOption.SortName]); + const obp = getSortByPreference(libraryId, sortByPreference); + _setSortBy([obp || SortByOption.SortName]); } - const fp = getFilterByPreference(libraryId, filterByPreference); - if (fp) { - _setFilterBy([fp]); + + // Apply filterBy: URL param > saved preference > default + if (urlFilterBy && Object.values(FilterByOption).includes(urlFilterBy)) { + _setFilterBy([urlFilterBy]); } else { - _setFilterBy([]); + const fp = getFilterByPreference(libraryId, filterByPreference); + _setFilterBy(fp ? [fp] : []); } }, [ libraryId, @@ -102,6 +117,9 @@ const Page = () => { _setSortBy, filterByPreference, _setFilterBy, + searchParams.sortBy, + searchParams.sortOrder, + searchParams.filterBy, ]); const setSortBy = useCallback( diff --git a/components/home/Home.tsx b/components/home/Home.tsx index 701c9949..30c3bebc 100644 --- a/components/home/Home.tsx +++ b/components/home/Home.tsx @@ -38,6 +38,7 @@ import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybac import { useDownload } from "@/providers/DownloadProvider"; import { useIntroSheet } from "@/providers/IntroSheetProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; +import { SortByOption, SortOrderOption } from "@/utils/atoms/filters"; import { useSettings } from "@/utils/atoms/settings"; import { eventBus } from "@/utils/eventBus"; import { storage } from "@/utils/mmkv"; @@ -50,6 +51,7 @@ type InfiniteScrollingCollectionListSection = { orientation?: "horizontal" | "vertical"; pageSize?: number; priority?: 1 | 2; // 1 = high priority (loads first), 2 = low priority + parentId?: string; // Library ID for "See All" navigation }; type MediaListSectionType = { @@ -230,6 +232,7 @@ export const Home = () => { }, type: "InfiniteScrollingCollectionList", pageSize, + parentId, }), [api, user?.Id], ); @@ -633,6 +636,18 @@ export const Home = () => { ) : null; if (section.type === "InfiniteScrollingCollectionList") { const isHighPriority = section.priority === 1; + const handleSeeAll = section.parentId + ? () => { + router.push({ + pathname: "/(auth)/(tabs)/(libraries)/[libraryId]", + params: { + libraryId: section.parentId!, + sortBy: SortByOption.DateCreated, + sortOrder: SortOrderOption.Descending, + }, + } as any); + } + : undefined; return ( { ? () => markSectionLoaded(section.queryKey) : undefined } + onPressSeeAll={handleSeeAll} /> {streamystatsSections}