mirror of
https://github.com/suitenumerique/meet.git
synced 2026-07-29 05:09:16 +00:00
✨(frontend) close admin side panel when the user is demoted
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.
This commit is contained in:
@@ -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 }),
|
||||
|
||||
Reference in New Issue
Block a user