1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-21 14:47:41 +01:00

replace sorting into filtering approach

This commit is contained in:
Ashishprasa 2024-01-01 22:59:33 +05:30
parent b9ec201c84
commit 1a62185c17

View file

@ -24,17 +24,12 @@ export async function searchForMedia(query: MWQuery): Promise<MediaItem[]> {
return formatTMDBMetaToMediaItem(formattedResult);
});
results.sort((a, b) => {
if (a.poster === undefined) {
return 1;
}
if (b.poster === undefined) {
return -1;
}
return 0;
});
const movieWithposters = results.filter((movie) => movie.poster);
const movieWithoutposters = results.filter((movie) => !movie.poster);
const sortedresult = movieWithposters.concat(movieWithoutposters);
// cache results for 1 hour
cache.set(query, results, 3600);
return results;
cache.set(query, sortedresult, 3600);
return sortedresult;
}