showing selected in footer
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
|||||||
Fab,
|
Fab,
|
||||||
Switch,
|
Switch,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
AvatarGroup,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { blueGrey } from '@mui/material/colors';
|
import { blueGrey } from '@mui/material/colors';
|
||||||
import { FiZap, FiHeadphones, FiLogOut, FiMonitor, FiSun } from 'react-icons/fi';
|
import { FiZap, FiHeadphones, FiLogOut, FiMonitor, FiSun } from 'react-icons/fi';
|
||||||
@@ -51,6 +52,7 @@ import MainPanel from './MainPanel';
|
|||||||
import { ConversationList } from './ConversationList';
|
import { ConversationList } from './ConversationList';
|
||||||
import NewConversationDialog from './NewConversationDialog';
|
import NewConversationDialog from './NewConversationDialog';
|
||||||
import { createGroupConversation } from '../firebase/firestore';
|
import { createGroupConversation } from '../firebase/firestore';
|
||||||
|
import ConversationLabel from '../subcomponents/ConversationLabel';
|
||||||
type ConversationMap = {
|
type ConversationMap = {
|
||||||
[conversationId: string]: Conversation;
|
[conversationId: string]: Conversation;
|
||||||
};
|
};
|
||||||
@@ -381,6 +383,11 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
navigator.mediaDevices
|
navigator.mediaDevices
|
||||||
.getUserMedia({ audio: true })
|
.getUserMedia({ audio: true })
|
||||||
.then((localUserMedia: MediaStream) => {
|
.then((localUserMedia: MediaStream) => {
|
||||||
|
if (!localUserMedia.active) {
|
||||||
|
enqueueSnackbar('Make sure your microphone is enabled!', { variant: 'error' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
localUserMedia.getTracks().forEach((track) => track.stop());
|
localUserMedia.getTracks().forEach((track) => track.stop());
|
||||||
|
|
||||||
setUserAudioStream(localUserMedia);
|
setUserAudioStream(localUserMedia);
|
||||||
@@ -415,7 +422,7 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!userAudioStream || !mediaRecorder) {
|
if (!userAudioStream || !mediaRecorder) {
|
||||||
enqueueSnackbar('Check your audio mic permissions in preferences!!', { variant: 'error' });
|
enqueueSnackbar('Configure your audio!!', { variant: 'error' });
|
||||||
|
|
||||||
handleAskForMicrophonePermissions();
|
handleAskForMicrophonePermissions();
|
||||||
return;
|
return;
|
||||||
@@ -423,12 +430,22 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
|
|
||||||
// prevent while delaying stopping
|
// prevent while delaying stopping
|
||||||
// ? better to just start after 200 ms as put below for the delay of stopping recording?
|
// ? better to just start after 200 ms as put below for the delay of stopping recording?
|
||||||
if (mediaRecorder.state === 'recording') return;
|
if (mediaRecorder.state === 'recording') {
|
||||||
|
enqueueSnackbar(`Please don't spam!!!`, { variant: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
enqueueSnackbar('started recording');
|
enqueueSnackbar('started recording');
|
||||||
setIsCloudDoingMagic(true);
|
setIsCloudDoingMagic(true);
|
||||||
mediaRecorder.start();
|
mediaRecorder.start();
|
||||||
setIsUserSpeaking(true);
|
setIsUserSpeaking(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
enqueueSnackbar('Problem in your audio!!!', { variant: 'error' });
|
||||||
|
setIsCloudDoingMagic(false);
|
||||||
|
setIsUserSpeaking(false);
|
||||||
|
}
|
||||||
}, [
|
}, [
|
||||||
selectedConversation,
|
selectedConversation,
|
||||||
setIsUserSpeaking,
|
setIsUserSpeaking,
|
||||||
@@ -564,7 +581,8 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
handleEscape,
|
handleEscape,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Grid container spacing={0}>
|
<Stack direction={'column'} sx={{ flex: 1 }}>
|
||||||
|
<Grid container spacing={0} sx={{ flex: 1 }}>
|
||||||
{/* side panel */}
|
{/* side panel */}
|
||||||
<Grid
|
<Grid
|
||||||
item
|
item
|
||||||
@@ -594,6 +612,10 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<MainPanel />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
{/* footer controls */}
|
{/* footer controls */}
|
||||||
<Box
|
<Box
|
||||||
@@ -657,6 +679,55 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
|
{selectedConversation && (
|
||||||
|
<Box sx={{ mx: 'auto' }}>
|
||||||
|
<Stack
|
||||||
|
direction={'row'}
|
||||||
|
sx={{
|
||||||
|
py: 2,
|
||||||
|
px: 2,
|
||||||
|
borderBottom: '1px solid',
|
||||||
|
borderBottomColor: blueGrey[100],
|
||||||
|
WebkitAppRegion: 'drag',
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
alignItems={'center'}
|
||||||
|
justifyContent={'flex-start'}
|
||||||
|
>
|
||||||
|
<IconButton color="primary" size="small">
|
||||||
|
<FiSun />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<Box sx={{ color: 'GrayText' }}>
|
||||||
|
<ConversationLabel
|
||||||
|
users={selectedConversation.userCache ?? []}
|
||||||
|
conversationName={selectedConversation.name}
|
||||||
|
isSelected={true}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<AvatarGroup variant={'rounded'}>
|
||||||
|
{selectedConversation.userCache?.map((conversationUser, index) => (
|
||||||
|
<Avatar
|
||||||
|
key={`${selectedConversation.id}-${conversationUser.uid}-convoIcon`}
|
||||||
|
alt={conversationUser?.displayName}
|
||||||
|
src={conversationUser?.photoUrl}
|
||||||
|
sx={{
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
opacity: selectedConversation.membersInRoom?.includes(
|
||||||
|
conversationUser.uid,
|
||||||
|
)
|
||||||
|
? '100%'
|
||||||
|
: '20%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</AvatarGroup>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* todo: add a third mode which is when toggle broadcasting */}
|
{/* todo: add a third mode which is when toggle broadcasting */}
|
||||||
{selectedConversation ? (
|
{selectedConversation ? (
|
||||||
<Tooltip title="Speak or toggle by clicking here!">
|
<Tooltip title="Speak or toggle by clicking here!">
|
||||||
@@ -716,10 +787,7 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Box>
|
</Box>
|
||||||
</Grid>
|
</Stack>
|
||||||
|
|
||||||
<MainPanel />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user