2026-03-07 18:03:32 +11:00
|
|
|
import React from 'react';
|
2026-09-19 12:52:03 -04:00
|
|
|
import { Box, Spinner, Text, color } from 'folds';
|
|
|
|
|
import { useAtomValue } from 'jotai';
|
2026-03-07 18:03:32 +11:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
import { LiveChip } from './LiveChip';
|
|
|
|
|
import * as css from './styles.css';
|
|
|
|
|
import { CallRoomName } from './CallRoomName';
|
|
|
|
|
import { CallControl } from './CallControl';
|
|
|
|
|
import { ContainerColor } from '../../styles/ContainerColor.css';
|
|
|
|
|
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
|
|
|
|
import { ScreenSize, useScreenSize } from '../../hooks/useScreenSize';
|
|
|
|
|
import { MemberGlance } from './MemberGlance';
|
|
|
|
|
import { StatusDivider } from './components';
|
|
|
|
|
import { CallEmbed } from '../../plugins/call/CallEmbed';
|
|
|
|
|
import { useCallJoined } from '../../hooks/useCallEmbed';
|
2026-03-08 22:00:35 +11:00
|
|
|
import { useCallSpeakers } from '../../hooks/useCallSpeakers';
|
|
|
|
|
import { MemberSpeaking } from './MemberSpeaking';
|
2026-09-19 12:52:03 -04:00
|
|
|
import { clockSkewAtom } from '../../state/clockSkew';
|
|
|
|
|
import { describeSkewVsServer } from '../../utils/clockSkew';
|
2026-03-07 18:03:32 +11:00
|
|
|
|
|
|
|
|
type CallStatusProps = {
|
|
|
|
|
callEmbed: CallEmbed;
|
|
|
|
|
};
|
|
|
|
|
export function CallStatus({ callEmbed }: CallStatusProps) {
|
|
|
|
|
const { room } = callEmbed;
|
|
|
|
|
|
|
|
|
|
const callSession = useCallSession(room);
|
2026-05-23 17:20:41 +05:30
|
|
|
const callMembers = useCallMembers(callSession);
|
2026-03-07 18:03:32 +11:00
|
|
|
const screenSize = useScreenSize();
|
|
|
|
|
const callJoined = useCallJoined(callEmbed);
|
2026-03-08 22:00:35 +11:00
|
|
|
const speakers = useCallSpeakers(callEmbed);
|
2026-09-19 12:52:03 -04:00
|
|
|
// [Gitea #158] Same warning as the top banner, where the user is looking during a call.
|
|
|
|
|
const clockSkew = useAtomValue(clockSkewAtom);
|
2026-03-08 22:00:35 +11:00
|
|
|
|
|
|
|
|
const compact = screenSize === ScreenSize.Mobile;
|
|
|
|
|
|
|
|
|
|
const memberVisible = callJoined && callMembers.length > 0;
|
2026-03-07 18:03:32 +11:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
className={classNames(css.CallStatus, ContainerColor({ variant: 'Background' }))}
|
|
|
|
|
shrink="No"
|
|
|
|
|
gap="400"
|
2026-03-08 22:00:35 +11:00
|
|
|
alignItems={compact ? undefined : 'Center'}
|
|
|
|
|
direction={compact ? 'Column' : 'Row'}
|
2026-03-07 18:03:32 +11:00
|
|
|
>
|
2026-03-08 22:00:35 +11:00
|
|
|
<Box grow="Yes" alignItems="Center" gap="200">
|
|
|
|
|
{memberVisible ? (
|
|
|
|
|
<Box shrink="No">
|
2026-03-07 18:03:32 +11:00
|
|
|
<LiveChip count={callMembers.length} room={room} members={callMembers} />
|
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
<Spinner variant="Secondary" size="200" />
|
|
|
|
|
)}
|
2026-03-09 14:04:48 +11:00
|
|
|
<Box grow="Yes" alignItems="Center" gap="Inherit">
|
|
|
|
|
{!compact && (
|
2026-03-08 22:00:35 +11:00
|
|
|
<>
|
2026-03-09 14:04:48 +11:00
|
|
|
<CallRoomName room={room} />
|
2026-09-19 12:52:03 -04:00
|
|
|
{clockSkew.warning && clockSkew.skewMs !== null && (
|
|
|
|
|
<>
|
|
|
|
|
<StatusDivider />
|
|
|
|
|
<Text
|
|
|
|
|
size="T200"
|
|
|
|
|
truncate
|
|
|
|
|
style={{ color: color.Warning.Main }}
|
|
|
|
|
title="Fix your computer's clock — calls and encryption depend on it"
|
|
|
|
|
>
|
|
|
|
|
Clock {describeSkewVsServer(clockSkew.skewMs)} — calls will fail
|
|
|
|
|
</Text>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2026-03-09 14:04:48 +11:00
|
|
|
{speakers.size > 0 && (
|
|
|
|
|
<>
|
|
|
|
|
<StatusDivider />
|
|
|
|
|
<span data-spacing-node />
|
|
|
|
|
<MemberSpeaking room={room} speakers={speakers} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2026-03-08 22:00:35 +11:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
{memberVisible && (
|
|
|
|
|
<Box shrink="No">
|
2026-06-19 16:41:57 -04:00
|
|
|
<MemberGlance
|
|
|
|
|
room={room}
|
|
|
|
|
members={callMembers}
|
|
|
|
|
speakers={speakers}
|
|
|
|
|
callEmbed={callEmbed}
|
|
|
|
|
/>
|
2026-03-08 22:00:35 +11:00
|
|
|
</Box>
|
|
|
|
|
)}
|
2026-03-07 18:03:32 +11:00
|
|
|
</Box>
|
2026-03-08 22:00:35 +11:00
|
|
|
{memberVisible && !compact && <StatusDivider />}
|
2026-03-09 14:04:48 +11:00
|
|
|
<Box shrink="No" alignItems="Center" gap="Inherit">
|
|
|
|
|
{compact && (
|
|
|
|
|
<Box grow="Yes">
|
|
|
|
|
<CallRoomName room={room} />
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2026-03-09 21:39:58 +11:00
|
|
|
<CallControl callJoined={callJoined} compact={compact} callEmbed={callEmbed} />
|
2026-03-07 18:03:32 +11:00
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|