Add UserCameraAvatar image and enhance SessionUsersPanel with session management features
- Introduced UserCameraAvatar.png for user camera display. - Updated SessionUsersPanel to accept a session prop, allowing for identification of local user as session organizer. - Implemented logic to determine if participants are organizers based on session data. - Adjusted admin control logic in UserCamera and UserCameraControls for better role management. - Improved logging and conditional rendering in ParticipantItem and UserCamera components for enhanced debugging and user experience.
This commit is contained in:
@@ -4,6 +4,9 @@ import DraggableContainer from "./DraggableContainer";
|
||||
import { useWebRTC } from "../hooks/useWebRTC";
|
||||
import clsx from "clsx";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { Session } from "../types/Session";
|
||||
import { getGuestId } from "../lib/guestId";
|
||||
import { useMe } from "../hooks/useAuth";
|
||||
|
||||
const LOCAL_CAMERAS_COUNT = 1;
|
||||
|
||||
@@ -11,12 +14,14 @@ interface SessionUsersPanelProps {
|
||||
roomId: string;
|
||||
autoJoin?: boolean;
|
||||
mode?: "full" | "mini";
|
||||
session?: Session;
|
||||
}
|
||||
|
||||
function SessionUsersPanel({
|
||||
roomId,
|
||||
autoJoin = false,
|
||||
mode = "full",
|
||||
session,
|
||||
}: SessionUsersPanelProps) {
|
||||
const {
|
||||
localStream,
|
||||
@@ -29,6 +34,22 @@ function SessionUsersPanel({
|
||||
} = useWebRTC(roomId, autoJoin);
|
||||
|
||||
const hasLocalStream = localStream !== null;
|
||||
const { data: user } = useMe();
|
||||
|
||||
// Определяем, является ли локальный пользователь организатором сессии
|
||||
const isLocalUserOrganizer = session
|
||||
? !!(session.userId && user?.id === session.userId) ||
|
||||
!!(session.guestId && getGuestId() === session.guestId)
|
||||
: false;
|
||||
|
||||
// Функция для определения, является ли конкретный участник организатором
|
||||
const isParticipantOrganizer = (participantId: string) => {
|
||||
if (!session) return false;
|
||||
return (
|
||||
(session.userId && participantId === session.userId) ||
|
||||
(session.guestId && participantId === session.guestId)
|
||||
);
|
||||
};
|
||||
|
||||
// Логируем изменения hasLocalStream для отладки
|
||||
useEffect(() => {
|
||||
@@ -180,8 +201,8 @@ function SessionUsersPanel({
|
||||
name="Вы"
|
||||
isMuted={isLocalAudioMuted}
|
||||
isVideoOff={isLocalVideoMuted}
|
||||
isControlDisabled={false}
|
||||
isAdmin={true}
|
||||
hasControl={false}
|
||||
isAdmin={isLocalUserOrganizer}
|
||||
isLocal={true}
|
||||
mediaStream={localStream}
|
||||
onMute={toggleAudio}
|
||||
@@ -214,8 +235,8 @@ function SessionUsersPanel({
|
||||
isMuted={participant.isMuted || false}
|
||||
isVideoOff={participant.isVideoOff || false}
|
||||
isSpeaking={participant.isSpeaking}
|
||||
isControlDisabled={true}
|
||||
isAdmin={false}
|
||||
hasControl={false}
|
||||
isAdmin={isParticipantOrganizer(participant.id) || undefined}
|
||||
mediaStream={participant.stream}
|
||||
hasLocalMediaPermission={hasLocalStream}
|
||||
onMute={() => console.log(`Mute user ${participant.id}`)}
|
||||
|
||||
Reference in New Issue
Block a user