From 53b43edc2a2ee4226f46854a9d187e7c3160c1cb Mon Sep 17 00:00:00 2001 From: Alex <111128610+Alexk2309@users.noreply.github.com> Date: Sun, 13 Jul 2025 04:47:26 +1000 Subject: [PATCH] Revert "fix: Recently Added isn't updating correctly." (#852) --- app/(auth)/(tabs)/(libraries)/[libraryId].tsx | 10 +--- components/posters/SeriesPoster.tsx | 1 - components/settings/HomeIndex.tsx | 58 ++++++------------- utils/atoms/filters.ts | 2 - 4 files changed, 18 insertions(+), 53 deletions(-) diff --git a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx index 929c098a..63dcf453 100644 --- a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx +++ b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx @@ -367,15 +367,7 @@ const Page = () => { className='mr-1' id={libraryId} queryKey='sortBy' - queryFn={async () => - sortOptions - .filter( - (s) => - library?.CollectionType !== "movies" || - s.key !== SortByOption.DateLastContentAdded, - ) - .map((s) => s.key) - } + queryFn={async () => sortOptions.map((s) => s.key)} set={setSortBy} values={sortBy} title={t("library.filters.sort_by")} diff --git a/components/posters/SeriesPoster.tsx b/components/posters/SeriesPoster.tsx index fd9466cd..2deba076 100644 --- a/components/posters/SeriesPoster.tsx +++ b/components/posters/SeriesPoster.tsx @@ -53,7 +53,6 @@ const SeriesPoster: React.FC = ({ item }) => { width: "100%", }} /> - {} ); }; diff --git a/components/settings/HomeIndex.tsx b/components/settings/HomeIndex.tsx index 4915c3b9..894e8702 100644 --- a/components/settings/HomeIndex.tsx +++ b/components/settings/HomeIndex.tsx @@ -213,43 +213,19 @@ export const HomeIndex = () => { queryKey, queryFn: async () => { if (!api) return []; - - const response = await getItemsApi(api).getItems({ - userId: user?.Id, - limit: 40, - recursive: true, - includeItemTypes, - sortBy: ["DateCreated"], - sortOrder: ["Descending"], - fields: ["PrimaryImageAspectRatio", "Path"], - parentId, - enableImageTypes: ["Primary", "Backdrop", "Thumb"], - }); - - let items = response.data.Items || []; - - if (includeItemTypes.includes("Episode")) { - // Removes individual episodes from the list if they are part of a series - // and only keeps the series item - // Note: The 'Latest' API endpoint does not work well with combining batch episode imports - // and will either only show the series or the episodes, not both. - // This is a workaround to filter out the episodes from the list - const seriesIds = new Set( - items.filter((i) => i.Type === "Series").map((i) => i.Id), - ); - - items = items.filter( - (i) => - i.Type === "Series" || - (i.Type === "Episode" && !seriesIds.has(i.SeriesId!)), - ); - } - - if (items.length > 20) { - items = items.slice(0, 20); - } - - return items; + return ( + ( + await getUserLibraryApi(api).getLatestMedia({ + userId: user?.Id, + limit: 20, + fields: ["PrimaryImageAspectRatio", "Path"], + imageTypeLimit: 1, + enableImageTypes: ["Primary", "Backdrop", "Thumb"], + includeItemTypes, + parentId, + }) + ).data || [] + ); }, type: "ScrollingCollectionList", }), @@ -263,7 +239,7 @@ export const HomeIndex = () => { const latestMediaViews = collections.map((c) => { const includeItemTypes: BaseItemKind[] = - c.CollectionType === "tvshows" ? ["Episode", "Series"] : ["Movie"]; + c.CollectionType === "tvshows" ? ["Series"] : ["Movie"]; const title = t("home.recently_added_in", { libraryName: c.Name }); const queryKey = [ "home", @@ -389,10 +365,10 @@ export const HomeIndex = () => { const response = await getTvShowsApi(api).getNextUp({ userId: user?.Id, fields: ["MediaSourceCount"], - limit: section.nextUp?.limit || 25, + limit: section.items?.limit || 25, enableImageTypes: ["Primary", "Backdrop", "Thumb"], - enableResumable: section.nextUp?.enableResumable, - enableRewatching: section.nextUp?.enableRewatching, + enableResumable: section.items?.enableResumable, + enableRewatching: section.items?.enableRewatching, }); return response.data.Items || []; } diff --git a/utils/atoms/filters.ts b/utils/atoms/filters.ts index 4ce23122..df9c5c78 100644 --- a/utils/atoms/filters.ts +++ b/utils/atoms/filters.ts @@ -8,7 +8,6 @@ export enum SortByOption { CommunityRating = "CommunityRating", CriticRating = "CriticRating", DateCreated = "DateCreated", - DateLastContentAdded = "DateLastContentAdded", DatePlayed = "DatePlayed", PlayCount = "PlayCount", ProductionYear = "ProductionYear", @@ -38,7 +37,6 @@ export const sortOptions: { { key: SortByOption.CommunityRating, value: "Community Rating" }, { key: SortByOption.CriticRating, value: "Critics Rating" }, { key: SortByOption.DateCreated, value: "Date Added" }, - { key: SortByOption.DateLastContentAdded, value: "Date Episode Added" }, { key: SortByOption.DatePlayed, value: "Date Played" }, { key: SortByOption.PlayCount, value: "Play Count" }, { key: SortByOption.ProductionYear, value: "Production Year" },