Sort then slice
This commit is contained in:
@@ -130,9 +130,7 @@
|
||||
|
||||
async function updateResults() {
|
||||
query = new Query(searchQuery)
|
||||
resultNotes = (await searchEngine.getSuggestions(query)).sort(
|
||||
(a, b) => b.score - a.score
|
||||
)
|
||||
resultNotes = await searchEngine.getSuggestions(query)
|
||||
selectedIndex = 0
|
||||
await scrollIntoView()
|
||||
}
|
||||
|
||||
@@ -247,7 +247,8 @@ export class Omnisearch {
|
||||
}
|
||||
}
|
||||
|
||||
results = results.slice(0, 50)
|
||||
// Sort results and keep the 50 best
|
||||
results = results.sort((a, b) => b.score - a.score).slice(0, 50)
|
||||
|
||||
const documents = await Promise.all(
|
||||
results.map(async result => await cacheManager.getDocument(result.id))
|
||||
|
||||
Reference in New Issue
Block a user