mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-06 23:51:28 +01:00
[PS-592] Name field is not prioritised in search results (#808)
* PS-592 Name field is not prioritised in search results - test search method which give priority to matches by Name * PS-592 Name field is not prioritised in search results - replaced used method with test method * PS-592 Name field is not prioritised in search results - Fixed code styling * PS-592 Name field is not prioritised in search results - avoid duplicates * PS-592 Name field is not prioritised in search results - let to const * PS-592 - ran prettier and lint Co-authored-by: André Bispo <abispo@bitwarden.com>
This commit is contained in:
parent
e61800d137
commit
400411b7a0
@ -188,29 +188,30 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
|
|
||||||
searchSends(sends: SendView[], query: string) {
|
searchSends(sends: SendView[], query: string) {
|
||||||
query = query.trim().toLocaleLowerCase();
|
query = query.trim().toLocaleLowerCase();
|
||||||
|
if (query === null) {
|
||||||
return sends.filter((s) => {
|
return sends;
|
||||||
if (s.name != null && s.name.toLowerCase().indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (
|
const sendsMatched: SendView[] = [];
|
||||||
|
const lowPriorityMatched: SendView[] = [];
|
||||||
|
sends.forEach((s) => {
|
||||||
|
if (s.name != null && s.name.toLowerCase().indexOf(query) > -1) {
|
||||||
|
sendsMatched.push(s);
|
||||||
|
} else if (
|
||||||
query.length >= 8 &&
|
query.length >= 8 &&
|
||||||
(s.id.startsWith(query) ||
|
(s.id.startsWith(query) ||
|
||||||
s.accessId.toLocaleLowerCase().startsWith(query) ||
|
s.accessId.toLocaleLowerCase().startsWith(query) ||
|
||||||
(s.file?.id != null && s.file.id.startsWith(query)))
|
(s.file?.id != null && s.file.id.startsWith(query)))
|
||||||
) {
|
) {
|
||||||
return true;
|
lowPriorityMatched.push(s);
|
||||||
}
|
} else if (s.notes != null && s.notes.toLowerCase().indexOf(query) > -1) {
|
||||||
if (s.notes != null && s.notes.toLowerCase().indexOf(query) > -1) {
|
lowPriorityMatched.push(s);
|
||||||
return true;
|
} else if (s.text?.text != null && s.text.text.toLowerCase().indexOf(query) > -1) {
|
||||||
}
|
lowPriorityMatched.push(s);
|
||||||
if (s.text?.text != null && s.text.text.toLowerCase().indexOf(query) > -1) {
|
} else if (s.file?.fileName != null && s.file.fileName.toLowerCase().indexOf(query) > -1) {
|
||||||
return true;
|
lowPriorityMatched.push(s);
|
||||||
}
|
|
||||||
if (s.file?.fileName != null && s.file.fileName.toLowerCase().indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return sendsMatched.concat(lowPriorityMatched);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexForSearch(): lunr.Index {
|
getIndexForSearch(): lunr.Index {
|
||||||
|
Loading…
Reference in New Issue
Block a user