diff --git a/src/frontend/src/components/Sidebar/UserList/index.tsx b/src/frontend/src/components/Sidebar/UserList/index.tsx index c6e89e3e..10a8cc1e 100644 --- a/src/frontend/src/components/Sidebar/UserList/index.tsx +++ b/src/frontend/src/components/Sidebar/UserList/index.tsx @@ -5,7 +5,6 @@ import { RedBlackTree } from '@/hooks/utils/RedBlackTree'; import { SidebarType } from '@/types/enums/SidebarType'; import { ProfileType } from '@/types/enums/ProfileType'; -import { UserRole } from '@/types/enums/UserRole'; import { roomApi } from '@/api/endpoints/room/room.api'; import { useWebSocketStore } from '@/stores/useWebSocketStore'; @@ -31,8 +30,8 @@ const compareUsers = (a: IUser, b: IUser): number => { export const UserList = () => { const treeRef = useRef | null>(null); const [, setVersion] = useState(0); - const { currentRoom } = useCurrentRoomStore(); - const roomId = currentRoom?.roomDetails.roomInfo[0]?.roomId; + const currentRoom = useCurrentRoomStore(state => state.currentRoom); + const roomId = useCurrentRoomStore(state => state.roomId); const { subscribeRoomUserInfo, subscribeRoomRoleChange } = useWebSocketStore.getState(); useEffect(() => { @@ -132,7 +131,7 @@ export const UserList = () => { nickname={member.nickname} imgUrl={member.profileImg} userRole={member.role} - myRole={UserRole.CREATOR} + myRole={currentRoom?.myRole || 2} sidebarType={SidebarType.USERLIST} onCancel={() => setActiveProfile(null)} /> diff --git a/src/frontend/src/components/Sidebar/VoiceChat/index.tsx b/src/frontend/src/components/Sidebar/VoiceChat/index.tsx index 6392846c..547edb2d 100644 --- a/src/frontend/src/components/Sidebar/VoiceChat/index.tsx +++ b/src/frontend/src/components/Sidebar/VoiceChat/index.tsx @@ -4,7 +4,6 @@ import { UserListFooter } from '@/components/Sidebar/UserList/UserListFooter'; import { SidebarType } from '@/types/enums/SidebarType'; import { ProfileType } from '@/types/enums/ProfileType'; -import { UserRole } from '@/types/enums/UserRole'; import { Container, UserList, ProfileWrapper } from './index.css'; import { CurrentRoomUserDto } from '@/api/endpoints/room/room.interface'; @@ -12,8 +11,9 @@ import { RoomProfileModal } from '@/components/Modal/RoomProfileModal'; import { useCurrentRoomStore } from '@/stores/useCurrentRoomStore'; export const VoiceChat = () => { const [activeProfile, setActiveProfile] = useState(null); - const { currentRoom } = useCurrentRoomStore(); - const roomId = currentRoom?.roomDetails.roomInfo[0]?.roomId; + + const currentRoom = useCurrentRoomStore(state => state.currentRoom); + const roomId = useCurrentRoomStore(state => state.roomId); const handleProfileClick = (id: number) => { setActiveProfile(prevId => (prevId === id ? null : id)); }; @@ -46,7 +46,7 @@ export const VoiceChat = () => { imgUrl={member.profileImageUrl} userId={member.userId} userRole={member.role} - myRole={UserRole.CREATOR} + myRole={currentRoom?.myRole || 2} sidebarType={SidebarType.VOICECHAT} roomId={roomId} onCancel={() => setActiveProfile(null)} diff --git a/src/frontend/src/components/YoutubePlayer/index.tsx b/src/frontend/src/components/YoutubePlayer/index.tsx index 6f6dcf8e..5089e6e8 100644 --- a/src/frontend/src/components/YoutubePlayer/index.tsx +++ b/src/frontend/src/components/YoutubePlayer/index.tsx @@ -7,10 +7,11 @@ import { UserRole } from '@/types/enums/UserRole'; export const YouTubePlayer = () => { const { videoQueue } = useVideoStore(); - const { roomId } = useCurrentRoomStore.getState(); + const currentRoom = useCurrentRoomStore(state => state.currentRoom); + const myRole = currentRoom?.myRole; + const roomId = useCurrentRoomStore(state => state.roomId); const { client, subTopic } = useWebSocketStore(); const pubTopic = useWebSocketStore.getState().pubTopic; - const myRole = useCurrentRoomStore.getState().currentRoom?.myRole; const isWatchOnly = myRole === UserRole.MEMBER; const playerRef = useRef(null);