1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

[Send] Add more flexibility to base component (#262)

* Updating send component for more flexibility in child class

* Updated delegte null check

* added comment
This commit is contained in:
Vincent Salucci 2021-02-08 16:18:44 -06:00 committed by GitHub
parent eef8a2a0f7
commit ee164bebc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,10 +38,12 @@ export class SendComponent implements OnInit {
searchPlaceholder: string; searchPlaceholder: string;
filter: (cipher: SendView) => boolean; filter: (cipher: SendView) => boolean;
searchPending = false; searchPending = false;
hasSearched = false; // search() function called - returns true if text qualifies for search
actionPromise: any; actionPromise: any;
onSuccessfulRemovePassword: () => Promise<any>; onSuccessfulRemovePassword: () => Promise<any>;
onSuccessfulDelete: () => Promise<any>; onSuccessfulDelete: () => Promise<any>;
onSuccessfulLoad: () => Promise<any>;
private searchTimeout: any; private searchTimeout: any;
@ -73,8 +75,6 @@ export class SendComponent implements OnInit {
} }
}); });
}); });
await this.load();
} }
ngOnDestroy() { ngOnDestroy() {
@ -85,6 +85,9 @@ export class SendComponent implements OnInit {
this.loading = true; this.loading = true;
const sends = await this.sendService.getAllDecrypted(); const sends = await this.sendService.getAllDecrypted();
this.sends = sends; this.sends = sends;
if (this.onSuccessfulLoad != null) {
await this.onSuccessfulLoad();
}
this.selectAll(); this.selectAll();
this.loading = false; this.loading = false;
this.loaded = true; this.loaded = true;
@ -116,12 +119,14 @@ export class SendComponent implements OnInit {
clearTimeout(this.searchTimeout); clearTimeout(this.searchTimeout);
} }
if (timeout == null) { if (timeout == null) {
this.hasSearched = this.searchService.isSearchable(this.searchText);
this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s));
this.applyTextSearch(); this.applyTextSearch();
return; return;
} }
this.searchPending = true; this.searchPending = true;
this.searchTimeout = setTimeout(async () => { this.searchTimeout = setTimeout(async () => {
this.hasSearched = this.searchService.isSearchable(this.searchText);
this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s));
this.applyTextSearch(); this.applyTextSearch();
this.searchPending = false; this.searchPending = false;
@ -142,7 +147,7 @@ export class SendComponent implements OnInit {
try { try {
this.actionPromise = this.sendService.removePasswordWithServer(s.id); this.actionPromise = this.sendService.removePasswordWithServer(s.id);
await this.actionPromise; await this.actionPromise;
if (this.onSuccessfulRemovePassword() != null) { if (this.onSuccessfulRemovePassword != null) {
this.onSuccessfulRemovePassword(); this.onSuccessfulRemovePassword();
} else { } else {
// Default actions // Default actions