From b018832fcf8a31be0fa156f4c1b411b06df2a2a9 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 28 Jul 2026 11:23:47 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(frontend)=20close=20admin=20side=20pa?= =?UTF-8?q?nel=20when=20the=20user=20is=20demoted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Listen to role changes in the admin panel and close the side panel if the current user is demoted while it is open. Without this, unprivileged users could still see the admin side panel until they closed it manually. I checked the other features that could be affected by hot role changes; this was the only one still exposing admin-only UI after a demotion. Everything else already handles live permission updates correctly. --- .../src/features/rooms/livekit/components/Admin.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/frontend/src/features/rooms/livekit/components/Admin.tsx b/src/frontend/src/features/rooms/livekit/components/Admin.tsx index 1ebbacda..8942de3b 100644 --- a/src/frontend/src/features/rooms/livekit/components/Admin.tsx +++ b/src/frontend/src/features/rooms/livekit/components/Admin.tsx @@ -11,6 +11,9 @@ import { useQuery } from '@tanstack/react-query' import { useParams } from 'wouter' import { usePublishSourcesManager } from '../hooks/usePublishSourcesManager' import { usePermissionsManager } from '../hooks/usePermissionsManager' +import { useEffect } from 'react' +import { closeSidePanel } from '@/stores/layout' +import { useIsAdminOrOwner } from '../hooks/useIsAdminOrOwner' export const Admin = () => { const { t } = useTranslation('rooms', { keyPrefix: 'admin' }) @@ -23,6 +26,14 @@ export const Admin = () => { const { mutateAsync: patchRoom } = usePatchRoom() + const isAdminOrOwner = useIsAdminOrOwner() + + useEffect(() => { + if (!isAdminOrOwner) { + closeSidePanel() + } + }, [isAdminOrOwner]) + const { data: readOnlyData } = useQuery({ queryKey: [keys.room, roomId], queryFn: () => fetchRoom({ roomId }),