Fix: Video Room Chat Header Button Removed (#11911)

* "@vector-im/compound-design-tokens": "^0.1.0"

* add chat button to room header for video rooms

* cleanup useEffect, comments

* comment
This commit is contained in:
Kerry 2023-11-22 10:28:54 +13:00 committed by GitHub
parent 4a0ffefae7
commit 668e3a3bd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 252 additions and 5 deletions

View file

@ -50,6 +50,7 @@ import { formatCount } from "../../../utils/FormattingUtils";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import { Linkify, topicToHtml } from "../../../HtmlUtils";
import PosthogTrackers from "../../../PosthogTrackers";
import { VideoRoomChatButton } from "./RoomHeader/VideoRoomChatButton";
/**
* A helper to transform a notification color to the what the Compound Icon Button
@ -215,6 +216,9 @@ export default function RoomHeader({
</Tooltip>
)}
{/* Renders nothing when room is not a video room */}
<VideoRoomChatButton room={room} />
<Tooltip label={_t("common|threads")}>
<IconButton
indicator={notificationColorToIndicator(threadNotifications)}

View file

@ -0,0 +1,75 @@
/*
Copyright 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { useContext } from "react";
import { Icon as ChatIcon } from "@vector-im/compound-design-tokens/icons/chat-solid.svg";
import { Room } from "matrix-js-sdk/src/matrix";
import { IconButton, Tooltip } from "@vector-im/compound-web";
import { isVideoRoom as calcIsVideoRoom } from "../../../../utils/video-rooms";
import { _t } from "../../../../languageHandler";
import { useEventEmitterState } from "../../../../hooks/useEventEmitter";
import { NotificationStateEvents } from "../../../../stores/notifications/NotificationState";
import { NotificationColor } from "../../../../stores/notifications/NotificationColor";
import { RightPanelPhases } from "../../../../stores/right-panel/RightPanelStorePhases";
import { SDKContext } from "../../../../contexts/SDKContext";
import { ButtonEvent } from "../../elements/AccessibleButton";
/**
* Display a button to toggle timeline for video rooms
* @param room
* @returns for a video room: a button to toggle timeline in the right panel
* otherwise null
*/
export const VideoRoomChatButton: React.FC<{ room: Room }> = ({ room }) => {
const sdkContext = useContext(SDKContext);
const isVideoRoom = calcIsVideoRoom(room);
const notificationState = isVideoRoom ? sdkContext.roomNotificationStateStore.getRoomState(room) : undefined;
const notificationColor = useEventEmitterState(
notificationState,
NotificationStateEvents.Update,
() => notificationState?.color,
);
if (!isVideoRoom) {
return null;
}
const displayUnreadIndicator =
!!notificationColor &&
[NotificationColor.Bold, NotificationColor.Grey, NotificationColor.Red].includes(notificationColor);
const onClick = (event: ButtonEvent): void => {
// stop event propagating up and triggering RoomHeader bar click
// which will open RoomSummary
event.stopPropagation();
sdkContext.rightPanelStore.showOrHidePanel(RightPanelPhases.Timeline);
};
return (
<Tooltip label={_t("right_panel|video_room_chat|title")}>
<IconButton
aria-label={_t("right_panel|video_room_chat|title")}
onClick={onClick}
indicator={displayUnreadIndicator ? "default" : undefined}
>
<ChatIcon />
</IconButton>
</Tooltip>
);
};