fix: deduplicate search results by path in useUnifiedSearch

This commit is contained in:
lucaronin
2026-02-27 15:42:14 +01:00
parent 464d143313
commit 8a38dfc3c7

View File

@@ -36,13 +36,20 @@ function searchWithTimeout(args: Record<string, unknown>, ms: number): Promise<S
}
function mapResults(raw: SearchResultData[]): SearchResult[] {
return raw.map(r => ({
title: r.title,
path: r.path,
snippet: r.snippet,
score: r.score,
noteType: r.note_type,
}))
const seen = new Set<string>()
return raw
.map(r => ({
title: r.title,
path: r.path,
snippet: r.snippet,
score: r.score,
noteType: r.note_type,
}))
.filter(r => {
if (seen.has(r.path)) return false
seen.add(r.path)
return true
})
}
export function useUnifiedSearch(vaultPath: string, active: boolean) {