Originally created by: ddlaurin
Closes [#153]
The org switcher gets its list from the user's memberships in
current-user-context. useDeleteOrganization invalidates the two organizations
list queries but not that one, so a deleted org stays in the switcher until you
reload the page. Clicking it gives "You do not have access to this organization".
useCreateOrganization already invalidates current-user-context. Delete just missed it.
Invalidate current-user-context on delete, same as create.
organizations.spec.ts already covered delete, but only asserted the toast and
the redirect so it passes with and without this bug.
The new test fakes the user endpoint so it returns two orgs before the delete
and one after, the way the real API would. Then it deletes an org and checks the
switcher drops it without a reload. It fails without the fix and passes with it.
pnpm exec tsc --noEmit clean
pnpm lint clean
pnpm exec playwright test 252 passed
Originally posted by: AnaniyaT
This refetch of
/auth/meruns concurrently with therouter.pushinorganization-detail.tsx. If the refetch resolves first,OrganizationProvidersees the URL org is gone and redirects to the fallback org, overriding the push. Worth checking whether that is a problem here.Originally posted by: ddlaurin
Reproduced. Tried moving the invalidation to
onSettled, but it still ran before the route change. Also tried putting it toorganization-detailbut the page unmounts when the navigation completes, so the effect is gone before the route changes.Ended up using the org store to temporarily save the org id that's being deleted.
OrganizationProviderskips the fallback redirect while the URL still points at that org, and clears the marker once the route has moved on.