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);
});
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;
}

View File

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