Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit eacb22e

Browse files
authored
Add chat button on new room header for maximised widgets (#12882)
* Add chat button to new room header for video room & maximised widgets Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshot Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update screenshot Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 0e37c09 commit eacb22e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed
-5 Bytes
Loading

src/components/structures/RoomView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ interface IRoomProps {
161161

162162
// This defines the content of the mainSplit.
163163
// If the mainSplit does not contain the Timeline, the chat is shown in the right panel.
164-
enum MainSplitContentType {
164+
export enum MainSplitContentType {
165165
Timeline,
166166
MaximisedWidget,
167167
Call,

src/components/views/rooms/RoomHeader.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { useCallback, useMemo, useState } from "react";
17+
import React, { useCallback, useContext, useMemo, useState } from "react";
1818
import { Body as BodyText, Button, IconButton, Menu, MenuItem, Tooltip } from "@vector-im/compound-web";
1919
import { Icon as VideoCallIcon } from "@vector-im/compound-design-tokens/icons/video-call-solid.svg";
2020
import { Icon as VoiceCallIcon } from "@vector-im/compound-design-tokens/icons/voice-call.svg";
@@ -50,7 +50,7 @@ import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
5050
import PosthogTrackers from "../../../PosthogTrackers";
5151
import { VideoRoomChatButton } from "./RoomHeader/VideoRoomChatButton";
5252
import { RoomKnocksBar } from "./RoomKnocksBar";
53-
import { isVideoRoom } from "../../../utils/video-rooms";
53+
import { useIsVideoRoom } from "../../../utils/video-rooms";
5454
import { notificationLevelToIndicator } from "../../../utils/notifications";
5555
import { CallGuestLinkButton } from "./RoomHeader/CallGuestLinkButton";
5656
import { ButtonEvent } from "../elements/AccessibleButton";
@@ -59,6 +59,8 @@ import { useIsReleaseAnnouncementOpen } from "../../../hooks/useIsReleaseAnnounc
5959
import { ReleaseAnnouncementStore } from "../../../stores/ReleaseAnnouncementStore";
6060
import WithPresenceIndicator, { useDmMember } from "../avatars/WithPresenceIndicator";
6161
import { IOOBData } from "../../../stores/ThreepidInviteStore";
62+
import RoomContext from "../../../contexts/RoomContext";
63+
import { MainSplitContentType } from "../../structures/RoomView";
6264

6365
export default function RoomHeader({
6466
room,
@@ -233,6 +235,13 @@ export default function RoomHeader({
233235

234236
const isReleaseAnnouncementOpen = useIsReleaseAnnouncementOpen("newRoomHeader");
235237

238+
const roomContext = useContext(RoomContext);
239+
const isVideoRoom = useIsVideoRoom(room);
240+
const showChatButton =
241+
isVideoRoom ||
242+
roomContext.mainSplitContentType === MainSplitContentType.MaximisedWidget ||
243+
roomContext.mainSplitContentType === MainSplitContentType.Call;
244+
236245
return (
237246
<>
238247
<Flex as="header" align="center" gap="var(--cpd-space-3x)" className="mx_RoomHeader light-panel">
@@ -325,14 +334,13 @@ export default function RoomHeader({
325334
})}
326335

327336
{isViewingCall && <CallGuestLinkButton room={room} />}
328-
{((isConnectedToCall && isViewingCall) || isVideoRoom(room)) && <VideoRoomChatButton room={room} />}
329337

330338
{hasActiveCallSession && !isConnectedToCall && !isViewingCall ? (
331339
joinCallButton
332340
) : (
333341
<>
334-
{!isVideoRoom(room) && videoCallButton}
335-
{!useElementCallExclusively && !isVideoRoom(room) && voiceCallButton}
342+
{!isVideoRoom && videoCallButton}
343+
{!useElementCallExclusively && !isVideoRoom && voiceCallButton}
336344
</>
337345
)}
338346

@@ -347,6 +355,9 @@ export default function RoomHeader({
347355
<RoomInfoIcon />
348356
</IconButton>
349357
</Tooltip>
358+
359+
{showChatButton && <VideoRoomChatButton room={room} />}
360+
350361
<Tooltip label={_t("common|threads")}>
351362
<IconButton
352363
indicator={notificationLevelToIndicator(threadNotifications)}

test/components/views/rooms/RoomHeader-test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ describe("RoomHeader", () => {
617617
},
618618
]);
619619
jest.spyOn(client, "isCryptoEnabled").mockReturnValue(true);
620+
jest.spyOn(ShieldUtils, "shieldStatusForRoom").mockResolvedValue(ShieldUtils.E2EStatus.Normal);
620621
});
621622

622623
it.each([

0 commit comments

Comments
 (0)