Skip to content

Commit 94d30c3

Browse files
committed
Review fixes
1 parent 5625784 commit 94d30c3

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/routes/admin/me_sessions.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ pub async fn delete_one(
120120
true
121121
}
122122
Ok(None) => false,
123-
Err(_) => false,
123+
Err(e) => {
124+
return Err(AdminError::Internal(format!(
125+
"Failed to look up session: {e}"
126+
)));
127+
}
124128
};
125129

126130
let result = session_store.delete_session(session_id).await;

ui/src/pages/AccountPage.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function AccountPage() {
6666
const { toast } = useToast();
6767
const confirm = useConfirm();
6868
const queryClient = useQueryClient();
69-
const [revokingSessionId, setRevokingSessionId] = useState<string | null>(null);
69+
const [revokingSessionIds, setRevokingSessionIds] = useState<Set<string>>(new Set());
7070

7171
// Export data query (only fetch when triggered)
7272
const { refetch: fetchExport, isFetching: isExporting } = useQuery({
@@ -79,15 +79,30 @@ export default function AccountPage() {
7979

8080
const deleteSessionMutation = useMutation({
8181
...meSessionsDeleteOneMutation(),
82-
onSuccess: () => {
83-
setRevokingSessionId(null);
82+
onSuccess: (_data, variables) => {
83+
setRevokingSessionIds((prev) => {
84+
const next = new Set(prev);
85+
next.delete(variables.path.session_id);
86+
return next;
87+
});
8488
queryClient.invalidateQueries({ queryKey: meSessionsListQueryKey() });
8589
},
86-
onError: () => setRevokingSessionId(null),
90+
onError: (error, variables) => {
91+
setRevokingSessionIds((prev) => {
92+
const next = new Set(prev);
93+
next.delete(variables.path.session_id);
94+
return next;
95+
});
96+
toast({
97+
title: "Failed to revoke session",
98+
description: String(error),
99+
type: "error",
100+
});
101+
},
87102
});
88103

89104
const handleRevokeSession = (sessionId: string) => {
90-
setRevokingSessionId(sessionId);
105+
setRevokingSessionIds((prev) => new Set(prev).add(sessionId));
91106
deleteSessionMutation.mutate({ path: { session_id: sessionId } });
92107
};
93108

@@ -295,7 +310,7 @@ export default function AccountPage() {
295310
key={session.id}
296311
session={session}
297312
onRevoke={handleRevokeSession}
298-
isRevoking={revokingSessionId === session.id}
313+
isRevoking={revokingSessionIds.has(session.id)}
299314
/>
300315
))}
301316
</div>

0 commit comments

Comments
 (0)