Skip to content

Commit 34fc921

Browse files
authored
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
1 parent c087755 commit 34fc921

File tree

5 files changed

+27
-234
lines changed

5 files changed

+27
-234
lines changed

playwright/e2e/invite/invite-dialog.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ test.describe("Invite dialog", function () {
113113
"rgba(0, 0, 0, 0)",
114114
);
115115

116+
await expect(page.locator(".mx_RoomView")).toMatchScreenshot("send_your_first_message_view.png");
117+
116118
// Send a message to invite the bots
117119
const composer = app.getComposer().locator("[contenteditable]");
118120
await composer.fill("Hello}");
27.3 KB
Loading

src/components/views/rooms/RoomHeader/RoomHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ import { RoomSettingsTab } from "../../dialogs/RoomSettingsDialog.tsx";
5454
import { useScopedRoomContext } from "../../../../contexts/ScopedRoomContext.tsx";
5555
import { ToggleableIcon } from "./toggle/ToggleableIcon.tsx";
5656
import { CurrentRightPanelPhaseContextProvider } from "../../../../contexts/CurrentRightPanelPhaseContext.tsx";
57+
import { type LocalRoom } from "../../../../models/LocalRoom.ts";
5758

5859
export default function RoomHeader({
5960
room,
6061
additionalButtons,
6162
oobData,
6263
}: {
63-
room: Room;
64+
room: Room | LocalRoom;
6465
additionalButtons?: ViewRoomOpts["buttons"];
6566
oobData?: IOOBData;
6667
}): JSX.Element {

src/hooks/room/useRoomCall.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { isVideoRoom } from "../../utils/video-rooms";
3636
import { UIFeature } from "../../settings/UIFeature";
3737
import { type InteractionName } from "../../PosthogTrackers";
3838
import { ElementCallMemberEventType } from "../../call-types";
39+
import { LocalRoom, LocalRoomState } from "../../models/LocalRoom";
3940

4041
export enum PlatformCallType {
4142
ElementCall,
@@ -83,7 +84,7 @@ const enum State {
8384
* @returns the call button attributes for the given room
8485
*/
8586
export const useRoomCall = (
86-
room: Room,
87+
room: Room | LocalRoom,
8788
): {
8889
voiceCallDisabledReason: string | null;
8990
voiceCallClick(evt: React.MouseEvent | undefined, selectedType: PlatformCallType): void;
@@ -274,11 +275,16 @@ export const useRoomCall = (
274275
});
275276
}, [isViewingCall, room.roomId]);
276277

278+
const roomDoesNotExist = room instanceof LocalRoom && room.state !== LocalRoomState.CREATED;
279+
277280
// We hide the voice call button if it'd have the same effect as the video call button
278281
let hideVoiceCallButton = isManagedHybridWidgetEnabled(room) || !callOptions.includes(PlatformCallType.LegacyCall);
279282
let hideVideoCallButton = false;
280-
// We hide both buttons if they require widgets but widgets are disabled, or if the Voip feature is disabled.
281-
if ((memberCount > 2 && !widgetsFeatureEnabled) || !voipFeatureEnabled) {
283+
// We hide both buttons if:
284+
// - they require widgets but widgets are disabled
285+
// - if the Voip feature is disabled.
286+
// - The room is not created yet (rendering "send first message view")
287+
if ((memberCount > 2 && !widgetsFeatureEnabled) || !voipFeatureEnabled || roomDoesNotExist) {
282288
hideVoiceCallButton = true;
283289
hideVideoCallButton = true;
284290
}

0 commit comments

Comments
 (0)