fix song header filter

This commit is contained in:
2026-03-15 13:21:17 +01:00
parent ab535d48b9
commit 9bbabb18aa

View File

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