fix(ui): remove deleted organization immediately from query cache and user...
run a fleet of AI agents on your own Kubernetes
Brought to you by:
agent-barn
Originally created by: amasen02
## Summary
Fixes [#153] — removes a deleted organization immediately from the UI list, infinite queries, and user organization context without requiring a manual page reload.
useDeleteOrganization in ui/src/features/organizations/hooks/use-organization-actions.ts did not update cached query pages upon deletion and omitted currentUserContextKey.all invalidation. Consequently:
platformOrganizationsKey.lists()) and the all-organizations query (platformOrganizationsKey.list({ scope: { mode: "all" } })) retained the deleted organization until the browser page was hard refreshed.currentUserContext cache (which drives userContext.organizationUsers in the OrgSwitcher and navbar) still listed the deleted organization.In useDeleteOrganization.onSuccess:
platformOrganizationsKey.lists() infinite query pages via queryClient.setQueriesData to immediately filter out the deleted organization (id !== organizationId) and decrement total.platformOrganizationsKey.list({ scope: { mode: "all" } }) to filter out the deleted item and decrement total.currentUserContextKey.all to immediately filter out organizationUsers where organizationId === organizationId.organizationsKey.detail(organizationId) and platformOrganizationsKey.detail(organizationId)).organizationsKey.lists(), platformOrganizationsKey.lists(), and currentUserContextKey.all.npx tsc --noEmit: 0 TypeScript errors.npx next build: production build completed cleanly with Turbopack (20/20 static and dynamic routes compiled successfully).