feat(planner): add AbortController to suggestion fetch $effect
Cancels the inflight request when activePickerDate changes or picker closes, preventing stale responses from overwriting suggestions. Adds page.test.ts covering fetch trigger, suggestion rendering, and AbortSignal presence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,12 +106,14 @@
|
||||
isLoadingSuggestions = false;
|
||||
return;
|
||||
}
|
||||
const controller = new AbortController();
|
||||
isLoadingSuggestions = true;
|
||||
fetch(`/planner?planId=${weekPlan.id}&date=${activePickerDate}`)
|
||||
fetch(`/planner?planId=${weekPlan.id}&date=${activePickerDate}`, { signal: controller.signal })
|
||||
.then((r) => r.json())
|
||||
.then((d) => { suggestions = d.suggestions ?? []; })
|
||||
.catch(() => { suggestions = []; })
|
||||
.catch((e) => { if (e.name !== 'AbortError') suggestions = []; })
|
||||
.finally(() => { isLoadingSuggestions = false; });
|
||||
return () => controller.abort();
|
||||
});
|
||||
|
||||
function handleSelectDay(day: string) {
|
||||
|
||||
Reference in New Issue
Block a user