forked from github/cinny
feat: show connected/connecting call status
This commit is contained in:
@@ -30,7 +30,7 @@ import { LocalRoomSummaryLoader } from '../../components/RoomSummaryLoader';
|
|||||||
import { UseStateProvider } from '../../components/UseStateProvider';
|
import { UseStateProvider } from '../../components/UseStateProvider';
|
||||||
import { RoomTopicViewer } from '../../components/room-topic-viewer';
|
import { RoomTopicViewer } from '../../components/room-topic-viewer';
|
||||||
import { onEnterOrSpace, stopPropagation } from '../../utils/keyboard';
|
import { onEnterOrSpace, stopPropagation } from '../../utils/keyboard';
|
||||||
import { Membership, RoomType } from '../../../types/matrix/room';
|
import { Membership } from '../../../types/matrix/room';
|
||||||
import * as css from './RoomItem.css';
|
import * as css from './RoomItem.css';
|
||||||
import * as styleCss from './style.css';
|
import * as styleCss from './style.css';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||||
|
|||||||
@@ -1,17 +1,34 @@
|
|||||||
import { Box, Chip, Icon, IconButton, Icons, Line, Text, Tooltip, TooltipProvider } from 'folds';
|
import {
|
||||||
|
Box,
|
||||||
|
Chip,
|
||||||
|
Icon,
|
||||||
|
IconButton,
|
||||||
|
Icons,
|
||||||
|
Line,
|
||||||
|
Spinner,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
TooltipProvider,
|
||||||
|
color,
|
||||||
|
} from 'folds';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
|
||||||
import { useCallState } from '../../pages/client/call/CallProvider';
|
import { useCallState } from '../../pages/client/call/CallProvider';
|
||||||
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
||||||
import * as css from './RoomCallNavStatus.css';
|
import * as css from './RoomCallNavStatus.css';
|
||||||
|
|
||||||
export function CallNavStatus() {
|
export function CallNavStatus() {
|
||||||
const { activeCallRoomId, isAudioEnabled, isVideoEnabled, toggleAudio, toggleVideo, hangUp } =
|
const {
|
||||||
useCallState();
|
activeCallRoomId,
|
||||||
const mx = useMatrixClient();
|
isActiveCallReady,
|
||||||
|
isAudioEnabled,
|
||||||
|
isVideoEnabled,
|
||||||
|
toggleAudio,
|
||||||
|
toggleVideo,
|
||||||
|
hangUp,
|
||||||
|
} = useCallState();
|
||||||
const { navigateRoom } = useRoomNavigate();
|
const { navigateRoom } = useRoomNavigate();
|
||||||
const hasActiveCall = Boolean(activeCallRoomId);
|
const hasActiveCall = Boolean(activeCallRoomId);
|
||||||
|
const isConnected = hasActiveCall && isActiveCallReady;
|
||||||
const handleGoToCallRoom = () => {
|
const handleGoToCallRoom = () => {
|
||||||
if (activeCallRoomId) {
|
if (activeCallRoomId) {
|
||||||
navigateRoom(activeCallRoomId);
|
navigateRoom(activeCallRoomId);
|
||||||
@@ -42,9 +59,17 @@ export function CallNavStatus() {
|
|||||||
ref={triggerRef}
|
ref={triggerRef}
|
||||||
className={css.RoomButton}
|
className={css.RoomButton}
|
||||||
>
|
>
|
||||||
<Icon size="300" src={Icons.VolumeHigh} />
|
{isConnected ? (
|
||||||
<Text className={css.RoomName} size="B400" truncate>
|
<Icon size="300" src={Icons.VolumeHigh} style={{ color: color.Success.Main }} />
|
||||||
{mx.getRoom(activeCallRoomId ?? '')?.name ?? ''}
|
) : (
|
||||||
|
<Spinner size="300" variant="Secondary" />
|
||||||
|
)}
|
||||||
|
<Text
|
||||||
|
as="span"
|
||||||
|
size="L400"
|
||||||
|
style={{ color: isConnected ? color.Success.Main : color.Warning.Main }}
|
||||||
|
>
|
||||||
|
{isConnected ? 'Connected' : 'Connecting'}
|
||||||
</Text>
|
</Text>
|
||||||
</Chip>
|
</Chip>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user