From ee164bebc65aa56e41a122eb4ece8971eb23119b Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Mon, 8 Feb 2021 16:18:44 -0600 Subject: [PATCH] [Send] Add more flexibility to base component (#262) * Updating send component for more flexibility in child class * Updated delegte null check * added comment --- src/angular/components/send/send.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/angular/components/send/send.component.ts b/src/angular/components/send/send.component.ts index 214db86731..8cf8acd3d7 100644 --- a/src/angular/components/send/send.component.ts +++ b/src/angular/components/send/send.component.ts @@ -38,10 +38,12 @@ export class SendComponent implements OnInit { searchPlaceholder: string; filter: (cipher: SendView) => boolean; searchPending = false; + hasSearched = false; // search() function called - returns true if text qualifies for search actionPromise: any; onSuccessfulRemovePassword: () => Promise; onSuccessfulDelete: () => Promise; + onSuccessfulLoad: () => Promise; private searchTimeout: any; @@ -73,8 +75,6 @@ export class SendComponent implements OnInit { } }); }); - - await this.load(); } ngOnDestroy() { @@ -85,6 +85,9 @@ export class SendComponent implements OnInit { this.loading = true; const sends = await this.sendService.getAllDecrypted(); this.sends = sends; + if (this.onSuccessfulLoad != null) { + await this.onSuccessfulLoad(); + } this.selectAll(); this.loading = false; this.loaded = true; @@ -116,12 +119,14 @@ export class SendComponent implements OnInit { clearTimeout(this.searchTimeout); } if (timeout == null) { + this.hasSearched = this.searchService.isSearchable(this.searchText); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s)); this.applyTextSearch(); return; } this.searchPending = true; this.searchTimeout = setTimeout(async () => { + this.hasSearched = this.searchService.isSearchable(this.searchText); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s)); this.applyTextSearch(); this.searchPending = false; @@ -142,7 +147,7 @@ export class SendComponent implements OnInit { try { this.actionPromise = this.sendService.removePasswordWithServer(s.id); await this.actionPromise; - if (this.onSuccessfulRemovePassword() != null) { + if (this.onSuccessfulRemovePassword != null) { this.onSuccessfulRemovePassword(); } else { // Default actions