Skip to content

Commit

Permalink
fix: Duplicated search result for series and movies
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-oki committed Sep 24, 2024
1 parent 5e08898 commit 79cc926
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions frontend/src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ function useSearch(query: string) {
return useMemo<SearchResultItem[]>(
() =>
data?.map((v) => {
let link: string;
if (v.sonarrSeriesId) {
link = `/series/${v.sonarrSeriesId}`;
} else if (v.radarrId) {
link = `/movies/${v.radarrId}`;
} else {
const { link, typeLabel } = (() => {
if (v.sonarrSeriesId) {
return { link: `/series/${v.sonarrSeriesId}`, typeLabel: "S" };
}

if (v.radarrId) {
return { link: `/movies/${v.radarrId}`, typeLabel: "M" };
}

throw new Error("Unknown search result");
}
})();

return {
value: `${v.title} (${v.year})`,
value: `${v.title} (${v.year}) (${typeLabel})`,
link,
};
}) ?? [],
Expand Down

0 comments on commit 79cc926

Please sign in to comment.