mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 12:58:53 +03:00
Use new setPhase helper in RoomHeader component
This commit is contained in:
parent
b37a808985
commit
9cfccda97e
1 changed files with 5 additions and 15 deletions
|
@ -27,7 +27,6 @@ import type { Room } from "matrix-js-sdk/src/matrix";
|
||||||
import { useRoomName } from "../../../hooks/useRoomName";
|
import { useRoomName } from "../../../hooks/useRoomName";
|
||||||
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
|
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
|
||||||
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
|
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
|
||||||
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
|
|
||||||
import { useTopic } from "../../../hooks/room/useTopic";
|
import { useTopic } from "../../../hooks/room/useTopic";
|
||||||
import { useAccountData } from "../../../hooks/useAccountData";
|
import { useAccountData } from "../../../hooks/useAccountData";
|
||||||
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
|
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
|
||||||
|
@ -46,6 +45,7 @@ import { useGlobalNotificationState } from "../../../hooks/useGlobalNotification
|
||||||
import SdkConfig from "../../../SdkConfig";
|
import SdkConfig from "../../../SdkConfig";
|
||||||
import { useFeatureEnabled } from "../../../hooks/useSettings";
|
import { useFeatureEnabled } from "../../../hooks/useSettings";
|
||||||
import FacePile from "../elements/FacePile";
|
import FacePile from "../elements/FacePile";
|
||||||
|
import { setPhase } from "../../../utils/room/setPhase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper to transform a notification color to the what the Compound Icon Button
|
* A helper to transform a notification color to the what the Compound Icon Button
|
||||||
|
@ -61,16 +61,6 @@ function notificationColorToIndicator(color: NotificationColor): React.Component
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A helper to show or hide the right panel
|
|
||||||
*/
|
|
||||||
function showOrHidePanel(phase: RightPanelPhases): void {
|
|
||||||
const rightPanel = RightPanelStore.instance;
|
|
||||||
rightPanel.isOpen && rightPanel.currentCard.phase === phase
|
|
||||||
? rightPanel.togglePanel(null)
|
|
||||||
: rightPanel.setCard({ phase });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
||||||
const client = useMatrixClientContext();
|
const client = useMatrixClientContext();
|
||||||
|
|
||||||
|
@ -139,7 +129,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
||||||
gap="var(--cpd-space-3x)"
|
gap="var(--cpd-space-3x)"
|
||||||
className="mx_RoomHeader light-panel"
|
className="mx_RoomHeader light-panel"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
showOrHidePanel(RightPanelPhases.RoomSummary);
|
setPhase(RightPanelPhases.RoomSummary);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DecoratedRoomAvatar room={room} size="40px" displayBadge={false} />
|
<DecoratedRoomAvatar room={room} size="40px" displayBadge={false} />
|
||||||
|
@ -185,7 +175,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
||||||
<IconButton
|
<IconButton
|
||||||
indicator={notificationColorToIndicator(threadNotifications)}
|
indicator={notificationColorToIndicator(threadNotifications)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
showOrHidePanel(RightPanelPhases.ThreadPanel);
|
setPhase(RightPanelPhases.ThreadPanel);
|
||||||
}}
|
}}
|
||||||
title={_t("common|threads")}
|
title={_t("common|threads")}
|
||||||
>
|
>
|
||||||
|
@ -194,7 +184,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
||||||
<IconButton
|
<IconButton
|
||||||
indicator={notificationColorToIndicator(globalNotificationState.color)}
|
indicator={notificationColorToIndicator(globalNotificationState.color)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
showOrHidePanel(RightPanelPhases.NotificationPanel);
|
setPhase(RightPanelPhases.NotificationPanel);
|
||||||
}}
|
}}
|
||||||
title={_t("Notifications")}
|
title={_t("Notifications")}
|
||||||
>
|
>
|
||||||
|
@ -208,7 +198,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
|
||||||
weight="medium"
|
weight="medium"
|
||||||
aria-label={_t("%(count)s members", { count: memberCount })}
|
aria-label={_t("%(count)s members", { count: memberCount })}
|
||||||
onClick={(e: React.MouseEvent) => {
|
onClick={(e: React.MouseEvent) => {
|
||||||
showOrHidePanel(RightPanelPhases.RoomMemberList);
|
setPhase(RightPanelPhases.RoomMemberList);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue