Skip to content

Commit

Permalink
enable search terms
Browse files Browse the repository at this point in the history
  • Loading branch information
rrchai committed Oct 25, 2023
1 parent 2117c35 commit aac992e
Showing 1 changed file with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,7 @@ export class ChallengeSearchComponent
takeUntil(this.destroy)
)
.subscribe((searched) => {
const searchedTerms = searched === '' ? undefined : searched;
this.router.navigate([], {
queryParamsHandling: 'merge',
queryParams: { searchTerms: searchedTerms },
});
this.onParamChange('searchTerms', searched);
});

this.query
Expand Down Expand Up @@ -437,16 +433,6 @@ export class ChallengeSearchComponent
this.destroy.complete();
}

splitParam(activeParam: string | undefined, by = ','): any[] {
return activeParam ? activeParam.split(by) : [];
}

collapseParam(selectedParam: any, by = ','): string | undefined {
return selectedParam.length === 0
? undefined
: this.splitParam(selectedParam.toString()).join(by);
}

onSearchChange(): void {
this.searchTerms.next(this.searchedTerms);
}
Expand Down Expand Up @@ -534,7 +520,7 @@ export class ChallengeSearchComponent
});
}

onParamChange(paramName: string, selected: string[]): void {
onParamChange(paramName: string, selected: string[] | string): void {
let params = new HttpParams().delete(paramName);
if (selected.length > 0) {
params = new HttpParams().append(
Expand All @@ -549,6 +535,16 @@ export class ChallengeSearchComponent
this.query.next(newQuery);
}

splitParam(activeParam: string | undefined, by = ','): any[] {
return activeParam ? activeParam.split(by) : [];
}

collapseParam(selectedParam: any, by = ','): string | undefined {
return selectedParam.length === 0
? undefined
: this.splitParam(selectedParam.toString()).join(by);
}

openSnackBar(message: string) {
this._snackBar.open(message, undefined, {
duration: 30000,
Expand Down

0 comments on commit aac992e

Please sign in to comment.