fix song header filter
This commit is contained in:
@@ -2,6 +2,7 @@ import {Component, DestroyRef, inject} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {ActivatedRoute, Params, Router} from '@angular/router';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {FilterStoreService} from '../../../../../services/filter-store.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-filter',
|
||||
@@ -12,6 +13,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
export class FilterComponent {
|
||||
private router = inject(Router);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private filterStore = inject(FilterStoreService);
|
||||
|
||||
public value = '';
|
||||
|
||||
@@ -20,11 +22,13 @@ export class FilterComponent {
|
||||
|
||||
activatedRoute.queryParams.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((params: Params) => {
|
||||
const typedParams = params as {q: string};
|
||||
if (typedParams.q) this.value = typedParams.q;
|
||||
this.value = typedParams.q ?? '';
|
||||
this.filterStore.updateSongFilter({q: this.value});
|
||||
});
|
||||
}
|
||||
|
||||
public async valueChange(text: string): Promise<void> {
|
||||
this.filterStore.updateSongFilter({q: text});
|
||||
const route = this.router.createUrlTree(['songs'], {
|
||||
queryParams: {q: text},
|
||||
queryParamsHandling: 'merge',
|
||||
|
||||
Reference in New Issue
Block a user