Show correct call icon for joining a call. (#31489)

* Show correct call icon in header.

* fix import

* Simply useRoomCall output

* Add tests and a label

* update snap

* update test
This commit is contained in:
Will Hunt
2026-01-02 17:51:15 +00:00
committed by GitHub
parent cbe3eb1709
commit 7398a83ae4
5 changed files with 53 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ import PublicIcon from "@vector-im/compound-design-tokens/assets/web/icons/publi
import { JoinRule, type Room } from "matrix-js-sdk/src/matrix";
import { type ViewRoomOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle";
import { Flex, Box } from "@element-hq/web-shared-components";
import { CallType } from "matrix-js-sdk/src/webrtc/call";
import { useRoomName } from "../../../../hooks/useRoomName.ts";
import { RightPanelPhases } from "../../../../stores/right-panel/RightPanelStorePhases.ts";
@@ -73,7 +74,7 @@ function RoomHeaderButtons({
toggleCallMaximized: toggleCall,
isViewingCall,
isConnectedToCall,
hasActiveCallSession,
activeCallSessionType,
callOptions,
showVoiceCallButton,
showVideoCallButton,
@@ -105,15 +106,26 @@ function RoomHeaderButtons({
);
const joinCallButton = (
<Tooltip label={videoCallDisabledReason ?? _t("voip|video_call")}>
<Tooltip
label={
videoCallDisabledReason ??
(activeCallSessionType === CallType.Voice ? _t("voip|voice_call") : _t("voip|video_call"))
}
>
<Button
size="sm"
onClick={videoClick}
Icon={VideoCallIcon}
// If we know this is a voice session, show the voice call. All other kinds of call are video calls.
Icon={activeCallSessionType === CallType.Voice ? VoiceCallIcon : VideoCallIcon}
className="mx_RoomHeader_join_button"
disabled={!!videoCallDisabledReason}
color="primary"
aria-label={videoCallDisabledReason ?? _t("action|join")}
aria-label={
videoCallDisabledReason ??
(activeCallSessionType === CallType.Voice
? _t("room|header|join_voice_call")
: _t("room|header|join_video_call"))
}
data-testId="join-call-button"
>
{_t("action|join")}
@@ -303,7 +315,7 @@ function RoomHeaderButtons({
{isViewingCall && <CallGuestLinkButton room={room} />}
{hasActiveCallSession && !isConnectedToCall && !isViewingCall ? (
{activeCallSessionType && !isConnectedToCall && !isViewingCall ? (
joinCallButton
) : (
<>

View File

@@ -93,7 +93,10 @@ export const useRoomCall = (
toggleCallMaximized: () => void;
isViewingCall: boolean;
isConnectedToCall: boolean;
hasActiveCallSession: boolean;
/**
* The type of call in progress, or `null` if no call is ongoing.
*/
activeCallSessionType: CallType | null;
callOptions: PlatformCallType[];
showVideoCallButton: boolean;
showVoiceCallButton: boolean;
@@ -123,13 +126,20 @@ export const useRoomCall = (
const groupCall = useCall(room.roomId);
const isConnectedToCall = useConnectionState(groupCall) === ConnectionState.Connected;
const hasGroupCall = groupCall !== null;
const hasActiveCallSession = useParticipantCount(groupCall) > 0;
const isViewingCall = useEventEmitterState(
roomViewStore,
UPDATE_EVENT,
() => roomViewStore.isViewingCall() || isVideoRoom(room),
);
const participantCount = useParticipantCount(groupCall);
const activeCallSessionType = useMemo(() => {
if (!groupCall || participantCount === 0) {
return null;
}
return groupCall.callType;
}, [participantCount, groupCall]);
// room
const memberCount = useRoomMemberCount(room);
@@ -307,7 +317,7 @@ export const useRoomCall = (
toggleCallMaximized: toggleCallMaximized,
isViewingCall: isViewingCall,
isConnectedToCall: isConnectedToCall,
hasActiveCallSession: hasActiveCallSession,
activeCallSessionType: activeCallSessionType,
callOptions,
showVoiceCallButton: !hideVoiceCallButton,
showVideoCallButton: !hideVideoCallButton,

View File

@@ -2029,6 +2029,8 @@
"forget_room": "Forget this room",
"forget_space": "Forget this space",
"header": {
"join_video_call": "Join video call",
"join_voice_call": "Join voice call",
"n_people_asking_to_join": {
"one": "Asking to join",
"other": "%(count)s people asking to join"