fix missing poster issu sort the movie list

This commit is contained in:
Ashishprasa 2023-12-30 21:57:24 +05:30
parent 445103958a
commit 986a46f9f0
2 changed files with 15 additions and 10 deletions

View File

@ -24,6 +24,17 @@ export async function searchForMedia(query: MWQuery): Promise<MediaItem[]> {
return formatTMDBMetaToMediaItem(formattedResult); 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; return results;
} }

View File

@ -67,8 +67,6 @@ export function SearchListPart({ searchQuery }: { searchQuery: string }) {
if (state.error) return <SearchSuffix failed />; if (state.error) return <SearchSuffix failed />;
if (!results) return null; if (!results) return null;
// console.log(results);
return ( return (
<div> <div>
{results.length > 0 ? ( {results.length > 0 ? (
@ -78,13 +76,9 @@ export function SearchListPart({ searchQuery }: { searchQuery: string }) {
icon={Icons.SEARCH} icon={Icons.SEARCH}
/> />
<MediaGrid> <MediaGrid>
{results.map((v) => {results.map((v) => (
v.poster === undefined ? ( <WatchedMediaCard key={v.id.toString()} media={v} />
"" ))}
) : (
<WatchedMediaCard key={v.id.toString()} media={v} />
),
)}
</MediaGrid> </MediaGrid>
</div> </div>
) : null} ) : null}