mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-07 01:13:21 +00:00
♻️(frontend) derive is_administrable from participant metadata
The is_administrable flag was previously read from the room API response through the room serializer, giving the frontend static information about the user's rights. Refactor the frontend so it derives this flag from the participant role carried in the participant metadata instead. Two benefits: * The flag now updates live along with the participant attributes/metadata, so role changes are reflected immediately. * It removes the duplication between the API response and the metadata, which both used to determine the user's capabilities.
This commit is contained in:
committed by
aleb_the_flash
parent
c55d8235fd
commit
7f386b2e2f
@@ -1,6 +1,17 @@
|
||||
import { useRoomData } from './useRoomData'
|
||||
import {
|
||||
useParticipantAttribute,
|
||||
useRoomContext,
|
||||
} from '@livekit/components-react'
|
||||
import { ParticipantRole } from '@/features/rooms/api/ApiRoom'
|
||||
|
||||
export const useIsAdminOrOwner = () => {
|
||||
const apiRoomData = useRoomData()
|
||||
return apiRoomData?.is_administrable
|
||||
const room = useRoomContext()
|
||||
const localParticipant = room.localParticipant
|
||||
const role = useParticipantAttribute('room_role', {
|
||||
participant: localParticipant,
|
||||
})
|
||||
return (
|
||||
role !== undefined &&
|
||||
['administrator', 'owner'].includes(role as ParticipantRole)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user