Files
cinny/src/app/pages/call/CallNavBottom.tsx
T

97 lines
2.7 KiB
TypeScript
Raw Normal View History

2025-04-21 01:38:08 -04:00
import { logger } from 'matrix-js-sdk/lib/logger';
import { useMatrixClient } from '../../hooks/useMatrixClient';
import { useCallState } from '../client/CallProvider';
2025-04-22 05:35:13 -04:00
import { Box, Chip, Icon, IconButton, Icons, Text } from 'folds';
import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
import {
makeMentionCustomProps,
renderMatrixMention,
} from '../../plugins/react-custom-html-parser';
2025-04-21 01:38:08 -04:00
export function CallNavBottom() {
const {
sendWidgetAction,
activeCallRoomId,
isAudioEnabled,
isVideoEnabled,
toggleAudio,
toggleVideo,
hangUp,
} = useCallState();
const mx = useMatrixClient();
const userName = mx.getUser(mx.getUserId() ?? '')?.displayName ?? mx.getUserId() ?? 'User';
const handleSendMessageClick = () => {
const action = 'my.custom.action';
const data = { message: `Hello from ${userName}!` };
logger.debug(`FixedBottomNavArea: Sending action '${action}'`);
sendWidgetAction(action, data)
.then(() => logger.info(`FixedBottomNavArea: Action '${action}' sent.`))
.catch((err) => logger.error(`FixedBottomNavArea: Failed action '${action}':`, err));
};
2025-04-22 05:35:13 -04:00
const mentionClickHandler = useMentionClickHandler(activeCallRoomId ?? mx.getUserId());
2025-04-21 01:38:08 -04:00
if (!activeCallRoomId) {
return (
<Box
direction="Column"
gap="500"
style={{
flexShrink: 0,
borderTop: `1px solid #e0e0e0`,
}}
>
<Text size="T200" color="Muted" align="Center">
No active call
</Text>
</Box>
);
}
2025-04-22 00:27:55 -04:00
//Muted:{(!isAudioEnabled).toString()}
//Videosn't:{(!isVideoEnabled).toString()}
/*
*/
2025-04-22 05:35:13 -04:00
const test = `https://matrix.to/#/${activeCallRoomId}`;
2025-04-21 01:38:08 -04:00
return (
2025-04-22 00:27:55 -04:00
<Box
direction="Column"
style={{
flexShrink: 0,
borderTop: `1px solid #e0e0e0`,
justifyContent: 'center',
}}
>
<Box direction="Row" style={{ justifyContent: 'center' }}>
2025-04-21 01:38:08 -04:00
{/* Going to need better icons for this */}
2025-04-22 00:27:55 -04:00
<IconButton onClick={toggleAudio}>
<Icon src={!isAudioEnabled ? Icons.VolumeHigh : Icons.VolumeMute} />
</IconButton>
<IconButton onClick={toggleVideo}>
<Icon src={!isVideoEnabled ? Icons.Vlc : Icons.Lock}></Icon>
</IconButton>
<IconButton onClick={hangUp}>
<Icon src={Icons.Phone}></Icon>
</IconButton>
2025-04-22 05:35:13 -04:00
<Box grow="Yes">
<Chip size="600">
{renderMatrixMention(
mx,
undefined,
test,
makeMentionCustomProps(
mentionClickHandler,
mx.getRoom(activeCallRoomId)?.normalizedName
)
)}
</Chip>
</Box>
2025-04-21 01:38:08 -04:00
</Box>
</Box>
);
}