mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Enable search for sends (#249)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { CipherView } from '../models/view/cipherView';
|
import { CipherView } from '../models/view/cipherView';
|
||||||
|
import { SendView } from '../models/view/sendView';
|
||||||
|
|
||||||
export abstract class SearchService {
|
export abstract class SearchService {
|
||||||
clearIndex: () => void;
|
clearIndex: () => void;
|
||||||
@@ -8,4 +9,5 @@ export abstract class SearchService {
|
|||||||
filter?: ((cipher: CipherView) => boolean) | (((cipher: CipherView) => boolean)[]),
|
filter?: ((cipher: CipherView) => boolean) | (((cipher: CipherView) => boolean)[]),
|
||||||
ciphers?: CipherView[]) => Promise<CipherView[]>;
|
ciphers?: CipherView[]) => Promise<CipherView[]>;
|
||||||
searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[];
|
searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[];
|
||||||
|
searchSends: (sends: SendView[], query: string) => SendView[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { SearchService as SearchServiceAbstraction } from '../abstractions/searc
|
|||||||
import { CipherType } from '../enums/cipherType';
|
import { CipherType } from '../enums/cipherType';
|
||||||
import { FieldType } from '../enums/fieldType';
|
import { FieldType } from '../enums/fieldType';
|
||||||
import { UriMatchType } from '../enums/uriMatchType';
|
import { UriMatchType } from '../enums/uriMatchType';
|
||||||
|
import { SendView } from '../models/view/sendView';
|
||||||
|
|
||||||
export class SearchService implements SearchServiceAbstraction {
|
export class SearchService implements SearchServiceAbstraction {
|
||||||
private indexing = false;
|
private indexing = false;
|
||||||
@@ -161,6 +162,28 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchSends(sends: SendView[], query: string) {
|
||||||
|
query = query.trim().toLocaleLowerCase();
|
||||||
|
|
||||||
|
return sends.filter(s => {
|
||||||
|
if (s.name != null && s.name.toLowerCase().indexOf(query) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (query.length >= 8 && (s.id.startsWith(query) || (s.file?.id != null && s.file.id.startsWith(query)))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (s.notes != null && s.notes.toLowerCase().indexOf(query) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (s.text?.text != null && s.text.text.toLowerCase().indexOf(query) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (s.file?.fileName != null && s.file.fileName.toLowerCase().indexOf(query) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getIndexForSearch(): lunr.Index {
|
getIndexForSearch(): lunr.Index {
|
||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user