1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

setting persons on the suggestions list with higher priority

This commit is contained in:
Patrik J. Braun 2021-05-04 21:32:25 +02:00
parent 0b24d60b44
commit 8b3f6ac64d

View File

@ -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);