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";
|
import { useSettings } from "@/utils/atoms/settings";
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const searchParams = useLocalSearchParams();
|
const searchParams = useLocalSearchParams() as {
|
||||||
const { libraryId } = searchParams as { libraryId: string };
|
libraryId: string;
|
||||||
|
sortBy?: string;
|
||||||
|
sortOrder?: string;
|
||||||
|
filterBy?: string;
|
||||||
|
};
|
||||||
|
const { libraryId } = searchParams;
|
||||||
|
|
||||||
const [api] = useAtom(apiAtom);
|
const [api] = useAtom(apiAtom);
|
||||||
const [user] = useAtom(userAtom);
|
const [user] = useAtom(userAtom);
|
||||||
@@ -76,23 +81,33 @@ const Page = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const sop = getSortOrderPreference(libraryId, sortOrderPreference);
|
// Check for URL params first (from "See All" navigation)
|
||||||
if (sop) {
|
const urlSortBy = searchParams.sortBy as SortByOption | undefined;
|
||||||
_setSortOrder([sop]);
|
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 {
|
} else {
|
||||||
_setSortOrder([SortOrderOption.Ascending]);
|
const sop = getSortOrderPreference(libraryId, sortOrderPreference);
|
||||||
|
_setSortOrder([sop || SortOrderOption.Ascending]);
|
||||||
}
|
}
|
||||||
const obp = getSortByPreference(libraryId, sortByPreference);
|
|
||||||
if (obp) {
|
// Apply sortBy: URL param > saved preference > default
|
||||||
_setSortBy([obp]);
|
if (urlSortBy && Object.values(SortByOption).includes(urlSortBy)) {
|
||||||
|
_setSortBy([urlSortBy]);
|
||||||
} else {
|
} else {
|
||||||
_setSortBy([SortByOption.SortName]);
|
const obp = getSortByPreference(libraryId, sortByPreference);
|
||||||
|
_setSortBy([obp || SortByOption.SortName]);
|
||||||
}
|
}
|
||||||
const fp = getFilterByPreference(libraryId, filterByPreference);
|
|
||||||
if (fp) {
|
// Apply filterBy: URL param > saved preference > default
|
||||||
_setFilterBy([fp]);
|
if (urlFilterBy && Object.values(FilterByOption).includes(urlFilterBy)) {
|
||||||
|
_setFilterBy([urlFilterBy]);
|
||||||
} else {
|
} else {
|
||||||
_setFilterBy([]);
|
const fp = getFilterByPreference(libraryId, filterByPreference);
|
||||||
|
_setFilterBy(fp ? [fp] : []);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
libraryId,
|
libraryId,
|
||||||
@@ -102,6 +117,9 @@ const Page = () => {
|
|||||||
_setSortBy,
|
_setSortBy,
|
||||||
filterByPreference,
|
filterByPreference,
|
||||||
_setFilterBy,
|
_setFilterBy,
|
||||||
|
searchParams.sortBy,
|
||||||
|
searchParams.sortOrder,
|
||||||
|
searchParams.filterBy,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const setSortBy = useCallback(
|
const setSortBy = useCallback(
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybac
|
|||||||
import { useDownload } from "@/providers/DownloadProvider";
|
import { useDownload } from "@/providers/DownloadProvider";
|
||||||
import { useIntroSheet } from "@/providers/IntroSheetProvider";
|
import { useIntroSheet } from "@/providers/IntroSheetProvider";
|
||||||
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
||||||
|
import { SortByOption, SortOrderOption } from "@/utils/atoms/filters";
|
||||||
import { useSettings } from "@/utils/atoms/settings";
|
import { useSettings } from "@/utils/atoms/settings";
|
||||||
import { eventBus } from "@/utils/eventBus";
|
import { eventBus } from "@/utils/eventBus";
|
||||||
import { storage } from "@/utils/mmkv";
|
import { storage } from "@/utils/mmkv";
|
||||||
@@ -50,6 +51,7 @@ type InfiniteScrollingCollectionListSection = {
|
|||||||
orientation?: "horizontal" | "vertical";
|
orientation?: "horizontal" | "vertical";
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
priority?: 1 | 2; // 1 = high priority (loads first), 2 = low priority
|
priority?: 1 | 2; // 1 = high priority (loads first), 2 = low priority
|
||||||
|
parentId?: string; // Library ID for "See All" navigation
|
||||||
};
|
};
|
||||||
|
|
||||||
type MediaListSectionType = {
|
type MediaListSectionType = {
|
||||||
@@ -230,6 +232,7 @@ export const Home = () => {
|
|||||||
},
|
},
|
||||||
type: "InfiniteScrollingCollectionList",
|
type: "InfiniteScrollingCollectionList",
|
||||||
pageSize,
|
pageSize,
|
||||||
|
parentId,
|
||||||
}),
|
}),
|
||||||
[api, user?.Id],
|
[api, user?.Id],
|
||||||
);
|
);
|
||||||
@@ -633,6 +636,18 @@ export const Home = () => {
|
|||||||
) : null;
|
) : null;
|
||||||
if (section.type === "InfiniteScrollingCollectionList") {
|
if (section.type === "InfiniteScrollingCollectionList") {
|
||||||
const isHighPriority = section.priority === 1;
|
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 (
|
return (
|
||||||
<View key={index} className='flex flex-col space-y-4'>
|
<View key={index} className='flex flex-col space-y-4'>
|
||||||
<InfiniteScrollingCollectionList
|
<InfiniteScrollingCollectionList
|
||||||
@@ -648,6 +663,7 @@ export const Home = () => {
|
|||||||
? () => markSectionLoaded(section.queryKey)
|
? () => markSectionLoaded(section.queryKey)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
onPressSeeAll={handleSeeAll}
|
||||||
/>
|
/>
|
||||||
{streamystatsSections}
|
{streamystatsSections}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user