From fd52489416fbd6633b65442f13265c09c8627c1e Mon Sep 17 00:00:00 2001 From: jhynsoo Date: Mon, 5 Aug 2024 15:55:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B0=95=EC=82=AC=EB=A7=8C=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EA=B3=B5=EC=9C=A0=20=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/LiveRoom/LiveRoom.jsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/LiveRoom/LiveRoom.jsx b/frontend/src/components/LiveRoom/LiveRoom.jsx index 6d52b2a..5295de5 100644 --- a/frontend/src/components/LiveRoom/LiveRoom.jsx +++ b/frontend/src/components/LiveRoom/LiveRoom.jsx @@ -15,17 +15,19 @@ import { useRoomInfo, useTracks, useParticipants, + useLocalParticipant, } from '@livekit/components-react'; import { RoomEvent, Track } from 'livekit-client'; -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import ChatRoom from '../ChatRoom/ChatRoom'; export default function LiveRoom() { const lastAutoFocusedScreenShareTrack = useRef(null); + const [role, setRole] = useState(null); - // get livekit identity const room = useRoomInfo(); const participants = useParticipants(); + const { localParticipant } = useLocalParticipant(); const tracks = useTracks( [ @@ -43,6 +45,16 @@ export default function LiveRoom() { const focusTrack = usePinnedTracks(layoutContext)?.[0]; const carouselTracks = tracks.filter((track) => !isEqualTrackRef(track, focusTrack)); + useEffect(() => { + try { + const role = JSON.parse(localParticipant.identity).role; + + setRole(role); + } catch (_) { + return; + } + }, [localParticipant.identity]); + useEffect(() => { if ( screenShareTracks.some((track) => track.publication.isSubscribed) && @@ -103,7 +115,7 @@ export default function LiveRoom() { )} - +