fix: optimistically remove dismissed app from sidebar cache
Sets query cache immediately on dismiss success so the sidebar updates without waiting for the catalog refetch to complete. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,7 +76,11 @@ export function useDismissApp() {
|
|||||||
if (res.status === 409) throw new Error('Cannot dismiss — live agents are still connected');
|
if (res.status === 409) throw new Error('Cannot dismiss — live agents are still connected');
|
||||||
if (!res.ok) throw new Error(`Failed to dismiss: ${res.status}`);
|
if (!res.ok) throw new Error(`Failed to dismiss: ${res.status}`);
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: (_data, applicationId) => {
|
||||||
|
// Optimistically remove from cache before refetch
|
||||||
|
qc.setQueriesData<CatalogApp[]>({ queryKey: ['catalog'] }, (old) =>
|
||||||
|
old ? old.filter((a) => a.slug !== applicationId) : old
|
||||||
|
);
|
||||||
qc.invalidateQueries({ queryKey: ['catalog'] });
|
qc.invalidateQueries({ queryKey: ['catalog'] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user