fix(dashboard): redirect after a member removes themselves
A member-with-app_admin who removes their own membership keeps a now-
broken Members tab open until reload — `myRole` is only computed once
in `loadApp`, and the next `/apps/{slug}` fetch would 403 anyway.
After the DELETE succeeds, if the removed user is the caller, navigate
back to /apps instead of refreshing the local member list.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
import ConfirmModal from '$lib/ConfirmModal.svelte';
|
||||
import ActionMenu from '$lib/ActionMenu.svelte';
|
||||
import RoleChip from '$lib/RoleChip.svelte';
|
||||
import { currentUser } from '$lib/auth';
|
||||
|
||||
const me = $derived($currentUser);
|
||||
|
||||
const SAMPLE_SOURCE =
|
||||
'#{\n statusCode: 200,\n body: #{ ok: true, echo: ctx.request.body }\n}';
|
||||
@@ -308,8 +311,16 @@
|
||||
removingMember = true;
|
||||
removeMemberError = null;
|
||||
try {
|
||||
const removedSelf = !!me && memberToRemove.user_id === me.id;
|
||||
await api.appMembers.remove(app.id, memberToRemove.user_id);
|
||||
memberToRemove = null;
|
||||
if (removedSelf) {
|
||||
// We just revoked our own access to this app; the next
|
||||
// fetch of /apps/{slug} would 403. Bounce back to the
|
||||
// apps list rather than render a broken tab.
|
||||
await goto(`${base}/apps`);
|
||||
return;
|
||||
}
|
||||
await loadMembers(app.id);
|
||||
} catch (e) {
|
||||
removeMemberError = e instanceof Error ? e.message : String(e);
|
||||
|
||||
Reference in New Issue
Block a user