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:
parent
0b24d60b44
commit
8b3f6ac64d
@ -135,6 +135,15 @@ export class AutoCompleteService {
|
|||||||
|
|
||||||
private sortResults(text: string, items: RenderableAutoCompleteItem[]): RenderableAutoCompleteItem[] {
|
private sortResults(text: string, items: RenderableAutoCompleteItem[]): RenderableAutoCompleteItem[] {
|
||||||
return items.sort((a, b) => {
|
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)) ||
|
if ((a.text.startsWith(text) && b.text.startsWith(text)) ||
|
||||||
(!a.text.startsWith(text) && !b.text.startsWith(text))) {
|
(!a.text.startsWith(text) && !b.text.startsWith(text))) {
|
||||||
return a.text.localeCompare(b.text);
|
return a.text.localeCompare(b.text);
|
||||||
|
Loading…
Reference in New Issue
Block a user