From 8b3f6ac64d0010bd547a15b8ca68541e8e4c7776 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Tue, 4 May 2021 21:32:25 +0200 Subject: [PATCH] setting persons on the suggestions list with higher priority --- .../app/ui/gallery/search/autocomplete.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/frontend/app/ui/gallery/search/autocomplete.service.ts b/src/frontend/app/ui/gallery/search/autocomplete.service.ts index fd028fcd..231072d4 100644 --- a/src/frontend/app/ui/gallery/search/autocomplete.service.ts +++ b/src/frontend/app/ui/gallery/search/autocomplete.service.ts @@ -135,6 +135,15 @@ export class AutoCompleteService { private sortResults(text: string, items: RenderableAutoCompleteItem[]): RenderableAutoCompleteItem[] { return items.sort((a, b) => { + // prioritize persons higher + if (a.type !== b.type) { + if (a.type === SearchQueryTypes.person) { + return -1; + } else if (b.type === SearchQueryTypes.person) { + return 1; + } + } + if ((a.text.startsWith(text) && b.text.startsWith(text)) || (!a.text.startsWith(text) && !b.text.startsWith(text))) { return a.text.localeCompare(b.text);