rescan: refetch inactive item lists too (works from any page)
invalidateQueries only refetches mounted queries, so a rescan pressed anywhere but the Tasks/Skills/… page just marked those lists stale — the new item wasn't picked up until you opened that page. Pass refetchType: 'all' so every item cache refreshes immediately, wherever the button is pressed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,10 @@ export function RescanButton() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await client.post<RescanResponse>('/rescan', {});
|
||||
await Promise.all(ITEM_QUERY_KEYS.map((key) => qc.invalidateQueries({ queryKey: [key] })));
|
||||
// refetchType: 'all' so INACTIVE (unmounted) item lists refetch too — otherwise a rescan from
|
||||
// anywhere but the Tasks/Skills/… page only marks them stale, and the change isn't picked up until
|
||||
// you next open that page. This refreshes every item cache immediately, wherever you press it.
|
||||
await Promise.all(ITEM_QUERY_KEYS.map((key) => qc.invalidateQueries({ queryKey: [key], refetchType: 'all' })));
|
||||
const c = res.counts ?? {};
|
||||
toast.success(`Rescanned items — ${c.tasks ?? 0} tasks, ${c.tools ?? 0} tools, ${c.skills ?? 0} skills, ${c.processes ?? 0} processes`);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user