// gomuks - A Matrix client written in Go. // Copyright (C) 2024 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . import type { IWidget } from "matrix-widget-api" import { JSX, use } from "react" import type { UserID } from "@/api/types" import MainScreenContext from "../MainScreenContext.ts" import ErrorBoundary from "../util/ErrorBoundary.tsx" import ElementCall from "../widget/ElementCall.tsx" import LazyWidget from "../widget/LazyWidget.tsx" import MemberList from "./MemberList.tsx" import PinnedMessages from "./PinnedMessages.tsx" import UserInfo from "./UserInfo.tsx" import WidgetList from "./WidgetList.tsx" import BackIcon from "@/icons/back.svg?react" import CloseIcon from "@/icons/close.svg?react" import "./RightPanel.css" export type RightPanelType = "pinned-messages" | "members" | "widgets" | "widget" | "user" | "element-call" interface RightPanelSimpleProps { type: "pinned-messages" | "members" | "widgets" | "element-call" } interface RightPanelWidgetProps { type: "widget" info: IWidget } interface RightPanelUserProps { type: "user" userID: UserID } export type RightPanelProps = RightPanelUserProps | RightPanelWidgetProps | RightPanelSimpleProps function getTitle(props: RightPanelProps): string { switch (props.type) { case "pinned-messages": return "Pinned Messages" case "members": return "Room Members" case "widgets": return "Widgets in room" case "widget": return props.info.name || "Widget" case "element-call": return "Element Call" case "user": return "User Info" } } function renderRightPanelContent(props: RightPanelProps): JSX.Element | null { switch (props.type) { case "pinned-messages": return case "members": return case "widgets": return case "element-call": return case "widget": return case "user": return } } const RightPanel = (props: RightPanelProps) => { const mainScreen = use(MainScreenContext) let backButton: JSX.Element | null = null if (props.type === "user") { backButton = } else if (props.type === "element-call" || props.type === "widget") { backButton = } return
{backButton}
{getTitle(props)}
{renderRightPanelContent(props)}
} export default RightPanel