Merge branch 'fe/screenSharePermission' into 'frontend'

feat: 강사만 화면 공유 할 수 있게 변경

See merge request s11-webmobile1-sub2/S11P12A701!48
This commit is contained in:
정기영 2024-08-05 15:56:51 +09:00
commit 7f3d00dda4

View File

@ -15,17 +15,19 @@ import {
useRoomInfo, useRoomInfo,
useTracks, useTracks,
useParticipants, useParticipants,
useLocalParticipant,
} from '@livekit/components-react'; } from '@livekit/components-react';
import { RoomEvent, Track } from 'livekit-client'; import { RoomEvent, Track } from 'livekit-client';
import { useEffect, useRef } from 'react'; import { useEffect, useRef, useState } from 'react';
import ChatRoom from '../ChatRoom/ChatRoom'; import ChatRoom from '../ChatRoom/ChatRoom';
export default function LiveRoom() { export default function LiveRoom() {
const lastAutoFocusedScreenShareTrack = useRef(null); const lastAutoFocusedScreenShareTrack = useRef(null);
const [role, setRole] = useState(null);
// get livekit identity
const room = useRoomInfo(); const room = useRoomInfo();
const participants = useParticipants(); const participants = useParticipants();
const { localParticipant } = useLocalParticipant();
const tracks = useTracks( const tracks = useTracks(
[ [
@ -43,6 +45,16 @@ export default function LiveRoom() {
const focusTrack = usePinnedTracks(layoutContext)?.[0]; const focusTrack = usePinnedTracks(layoutContext)?.[0];
const carouselTracks = tracks.filter((track) => !isEqualTrackRef(track, focusTrack)); const carouselTracks = tracks.filter((track) => !isEqualTrackRef(track, focusTrack));
useEffect(() => {
try {
const role = JSON.parse(localParticipant.identity).role;
setRole(role);
} catch (_) {
return;
}
}, [localParticipant.identity]);
useEffect(() => { useEffect(() => {
if ( if (
screenShareTracks.some((track) => track.publication.isSubscribed) && screenShareTracks.some((track) => track.publication.isSubscribed) &&
@ -103,7 +115,7 @@ export default function LiveRoom() {
</FocusLayoutContainer> </FocusLayoutContainer>
</div> </div>
)} )}
<ControlBar controls={{ chat: false, leave: false }} /> <ControlBar controls={{ chat: false, leave: false, screenShare: role === '강사' }} />
</div> </div>
<ChatRoom /> <ChatRoom />
</LayoutContextProvider> </LayoutContextProvider>