Skip to content

Commit

Permalink
fix: frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Nov 14, 2023
1 parent 4ac824e commit a3ce251
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/angular/src/app/doc-search/doc-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { DocumentSearch } from '../model/documents';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { map, tap } from 'rxjs/operators';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { interval } from 'rxjs';
import { Subscription, interval } from 'rxjs';


@Component({
Expand All @@ -39,6 +39,7 @@ export class DocSearchComponent {
protected searchResults: string[] = [];
protected searching = false;
protected msWorking = 0;
private repeatSub: Subscription | null = null;

constructor(private destroyRef: DestroyRef, private router: Router, private documentService: DocumentService) { }

Expand All @@ -51,13 +52,14 @@ export class DocSearchComponent {
const startDate = new Date();
this.msWorking = 0;
this.searching = true;
const repeatSub = interval(100).pipe(map(() => new Date())).subscribe(newDate => this.msWorking = newDate.getTime() - startDate.getTime());
this.repeatSub?.unsubscribe();
this.repeatSub = interval(100).pipe(map(() => new Date()), takeUntilDestroyed(this.destroyRef)).subscribe(newDate => this.msWorking = newDate.getTime() - startDate.getTime());
const documentSearch = {searchString: this.searchValueControl.value} as DocumentSearch;
this.documentService.postDocumentSearch(documentSearch)
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.searching = false), tap(() => repeatSub.unsubscribe()))
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.searching = false), tap(() => this.repeatSub?.unsubscribe()))
.subscribe(result => {
this.searchResults = result.resultStrings;
//console.log(this.searchResults);
console.log(this.searchResults);
});
}

Expand Down

0 comments on commit a3ce251

Please sign in to comment.