mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
feat(home): add see all navigation from recently added sections
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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 (
|
||||
<View key={index} className='flex flex-col space-y-4'>
|
||||
<InfiniteScrollingCollectionList
|
||||
@@ -648,6 +663,7 @@ export const Home = () => {
|
||||
? () => markSectionLoaded(section.queryKey)
|
||||
: undefined
|
||||
}
|
||||
onPressSeeAll={handleSeeAll}
|
||||
/>
|
||||
{streamystatsSections}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user