import {
Avatar,
AvatarGroup,
Card,
CardMedia,
Container,
Divider,
Fab,
Grid,
IconButton,
Slider,
Stack,
Tooltip,
Typography,
} from '@mui/material';
import { FiAirplay, FiLink, FiSun, FiUserPlus, FiZap } from 'react-icons/fi';
import React, { useEffect, useMemo, useRef } from 'react';
import { Box } from '@mui/system';
import ConversationLabel from '../subcomponents/ConversationLabel';
import { MasterConversation } from '../util/types';
// import ConversationDetails from './ConversationDetails';
import { blueGrey } from '@mui/material/colors';
import useAuth from '../providers/AuthProvider';
import useConversations from '../providers/ConversationProvider';
import { useRendersCount } from 'react-use';
export default function MainPanel() {
const { user } = useAuth();
const { selectedConversation } = useConversations();
// if selected conversation, show details
// do all fetching necessary to paint things here
// render room contents if there are people with video or other tracks
const rendersCount = useRendersCount();
// console.warn('RENDER COUNT | MAINPANEL | ', rendersCount);
if (selectedConversation)
return ;
return (
{`Hi ${user.givenName?.split(' ')[0] ?? 'there'}!`}
Start a conversation with one tap
or just take a breather.
);
}
function ConversationDetails({ masterConversation }: { masterConversation: MasterConversation }) {
const { user } = useAuth();
const isPriority = useMemo(() => {
const personalConvoMember = masterConversation.members.find(
(mem) => mem._id.toString() === user._id.toString(),
);
if (personalConvoMember && personalConvoMember.memberState === 'priority') {
return true;
}
return false;
}, [masterConversation, user]);
return (
{/* conversation header details and controls */}
{/* conversation controls */}
{isPriority ? (
) : (
)}
{/* live video and screenshares */}
{masterConversation.room &&
Object.entries(masterConversation.room).map(([userId, userPeerContents]) => {
return (
);
})}
{/* main canvas */}
last week
yesterday
today
);
}
function Video({ stream }: { stream: MediaStream }) {
const videoRef = useRef(null);
useEffect(() => {
if (stream && videoRef.current) {
videoRef.current.srcObject = stream;
videoRef.current.autoplay = true;
videoRef.current.muted = true;
}
}, [stream]);
return (
);
}
const marks = [
{
value: 0,
label: 'Arjun',
avatar: ,
},
{
value: 20,
label: 'Nick',
avatar: ,
},
{
value: 37,
label: 'Jeremy',
avatar: ,
},
{
value: 100,
label: '43 sec',
avatar: ,
},
];
function valuetext(value: number) {
return `${value}°C`;
}
// TODO: get label based on what region we are in
function valueLabelFormat(value: number) {
return (
marks.find((mark) => mark.value === value)?.avatar ?? (
)
);
}
function ConversationChunk() {
return (
Monday
2:30pm
6/18/22
);
}