diff --git a/src/hooks/useDiscover.ts b/src/hooks/useDiscover.ts index 2a2acd02f..8e53494f0 100644 --- a/src/hooks/useDiscover.ts +++ b/src/hooks/useDiscover.ts @@ -10,6 +10,7 @@ export interface BaseSearchResult { } interface BaseMedia { + id: number; mediaType: string; mediaInfo?: { status: MediaStatus; @@ -82,6 +83,8 @@ const useDiscover = < } ); + const resultIds: Set = new Set(); + const isLoadingInitialData = !data && !error; const isLoadingMore = isLoadingInitialData || @@ -94,7 +97,18 @@ const useDiscover = < setSize(size + 1); }; - let titles = (data ?? []).reduce((a, v) => [...a, ...v.results], [] as T[]); + let titles = (data ?? []).reduce((a, v) => { + const results: T[] = []; + + for (const result of v.results) { + if (!resultIds.has(result.id)) { + resultIds.add(result.id); + results.push(result); + } + } + + return [...a, ...results]; + }, [] as T[]); if (settings.currentSettings.hideAvailable && hideAvailable) { titles = titles.filter(