@@ -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