Hide calling buttons in room header before a room is created (#30816)

* Hide call buttons until room has been created.

* lint

* lint

* Update snapshot

* update snaps
This commit is contained in:
Will Hunt
2025-10-06 14:17:31 +00:00
committed by GitHub
parent c08775588d
commit 34fc921cd3
5 changed files with 27 additions and 234 deletions
@@ -54,13 +54,14 @@ import { RoomSettingsTab } from "../../dialogs/RoomSettingsDialog.tsx";
import { useScopedRoomContext } from "../../../../contexts/ScopedRoomContext.tsx";
import { ToggleableIcon } from "./toggle/ToggleableIcon.tsx";
import { CurrentRightPanelPhaseContextProvider } from "../../../../contexts/CurrentRightPanelPhaseContext.tsx";
import { type LocalRoom } from "../../../../models/LocalRoom.ts";
export default function RoomHeader({
room,
additionalButtons,
oobData,
}: {
room: Room;
room: Room | LocalRoom;
additionalButtons?: ViewRoomOpts["buttons"];
oobData?: IOOBData;
}): JSX.Element {
+9 -3
View File
@@ -36,6 +36,7 @@ import { isVideoRoom } from "../../utils/video-rooms";
import { UIFeature } from "../../settings/UIFeature";
import { type InteractionName } from "../../PosthogTrackers";
import { ElementCallMemberEventType } from "../../call-types";
import { LocalRoom, LocalRoomState } from "../../models/LocalRoom";
export enum PlatformCallType {
ElementCall,
@@ -83,7 +84,7 @@ const enum State {
* @returns the call button attributes for the given room
*/
export const useRoomCall = (
room: Room,
room: Room | LocalRoom,
): {
voiceCallDisabledReason: string | null;
voiceCallClick(evt: React.MouseEvent | undefined, selectedType: PlatformCallType): void;
@@ -274,11 +275,16 @@ export const useRoomCall = (
});
}, [isViewingCall, room.roomId]);
const roomDoesNotExist = room instanceof LocalRoom && room.state !== LocalRoomState.CREATED;
// We hide the voice call button if it'd have the same effect as the video call button
let hideVoiceCallButton = isManagedHybridWidgetEnabled(room) || !callOptions.includes(PlatformCallType.LegacyCall);
let hideVideoCallButton = false;
// We hide both buttons if they require widgets but widgets are disabled, or if the Voip feature is disabled.
if ((memberCount > 2 && !widgetsFeatureEnabled) || !voipFeatureEnabled) {
// We hide both buttons if:
// - they require widgets but widgets are disabled
// - if the Voip feature is disabled.
// - The room is not created yet (rendering "send first message view")
if ((memberCount > 2 && !widgetsFeatureEnabled) || !voipFeatureEnabled || roomDoesNotExist) {
hideVoiceCallButton = true;
hideVideoCallButton = true;
}