fix(search): Race-Guard-Test korrekt auf in-flight abzielen
Der vorherige Test setzte query NACH dem Fetch-Abschluss und erzwang dafuer einen setter-Side-Effect, der bei normalem Tippen die Treffer waehrend des Debounce-Fensters fuer 300ms leer geblitzt haette. Jetzt: echter Race-Test mit manuell aufloesbarem fetch. Setter-Nebenwirkung entfernt, query ist wieder plain \$state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ export type SearchStoreOptions = {
|
||||
};
|
||||
|
||||
export class SearchStore {
|
||||
#query = $state('');
|
||||
query = $state('');
|
||||
hits = $state<SearchHit[]>([]);
|
||||
webHits = $state<WebHit[]>([]);
|
||||
searching = $state(false);
|
||||
@@ -34,21 +34,6 @@ export class SearchStore {
|
||||
webExhausted = $state(false);
|
||||
loadingMore = $state(false);
|
||||
|
||||
get query(): string {
|
||||
return this.#query;
|
||||
}
|
||||
|
||||
set query(v: string) {
|
||||
this.#query = v;
|
||||
// Race-guard: when the query diverges from the last committed search,
|
||||
// any currently shown hits are stale and must be cleared immediately.
|
||||
if (this.searchedFor !== null && v.trim() !== this.searchedFor) {
|
||||
this.hits = [];
|
||||
this.webHits = [];
|
||||
this.searchedFor = null;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly pageSize: number;
|
||||
private readonly debounceMs: number;
|
||||
private readonly filterDebounceMs: number;
|
||||
|
||||
Reference in New Issue
Block a user