From 986a46f9f03dafbf48daf30314ab497ba509c87f Mon Sep 17 00:00:00 2001 From: Ashishprasa Date: Sat, 30 Dec 2023 21:57:24 +0530 Subject: [PATCH] fix missing poster issu sort the movie list --- src/backend/metadata/search.ts | 13 ++++++++++++- src/pages/parts/search/SearchListPart.tsx | 12 +++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/backend/metadata/search.ts b/src/backend/metadata/search.ts index a162dd3a..f7984edc 100644 --- a/src/backend/metadata/search.ts +++ b/src/backend/metadata/search.ts @@ -24,6 +24,17 @@ export async function searchForMedia(query: MWQuery): Promise { return formatTMDBMetaToMediaItem(formattedResult); }); - cache.set(query, results, 3600); // cache results for 1 hour + cache.set(query, results, 3600); + + results.sort((a, b) => { + if (a.poster === undefined) { + return 1; + } + if (b.poster === undefined) { + return -1; + } + return 0; + }); + // cache results for 1 hour return results; } diff --git a/src/pages/parts/search/SearchListPart.tsx b/src/pages/parts/search/SearchListPart.tsx index ea9a5f43..270d05f1 100644 --- a/src/pages/parts/search/SearchListPart.tsx +++ b/src/pages/parts/search/SearchListPart.tsx @@ -67,8 +67,6 @@ export function SearchListPart({ searchQuery }: { searchQuery: string }) { if (state.error) return ; if (!results) return null; - // console.log(results); - return (
{results.length > 0 ? ( @@ -78,13 +76,9 @@ export function SearchListPart({ searchQuery }: { searchQuery: string }) { icon={Icons.SEARCH} /> - {results.map((v) => - v.poster === undefined ? ( - "" - ) : ( - - ), - )} + {results.map((v) => ( + + ))}
) : null}