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

Make room model mandatory on the RoomHeader #11355

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function LocalRoomView(props: LocalRoomViewProps): ReactElement {
<div className="mx_RoomView mx_RoomView--local">
<ErrorBoundary>
{SettingsStore.getValue("feature_new_room_decoration_ui") ? (
<RoomHeader room={context.room} />
<RoomHeader room={room} />
) : (
<LegacyRoomHeader
room={context.room}
Expand Down Expand Up @@ -345,16 +345,15 @@ interface ILocalRoomCreateLoaderProps {
* @return {ReactElement}
*/
function LocalRoomCreateLoader(props: ILocalRoomCreateLoaderProps): ReactElement {
const context = useContext(RoomContext);
const text = _t("We're creating a room with %(names)s", { names: props.names });
return (
<div className="mx_RoomView mx_RoomView--local">
<ErrorBoundary>
{SettingsStore.getValue("feature_new_room_decoration_ui") ? (
<RoomHeader room={context.room} />
<RoomHeader room={props.localRoom} />
) : (
<LegacyRoomHeader
room={context.room}
room={props.localRoom}
searchInfo={undefined}
inRoom={true}
onSearchClick={null}
Expand Down Expand Up @@ -2470,7 +2469,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
)}
<ErrorBoundary>
{SettingsStore.getValue("feature_new_room_decoration_ui") ? (
<RoomHeader room={this.state.room} oobData={this.props.oobData} />
<RoomHeader room={this.state.room} />
) : (
<LegacyRoomHeader
room={this.state.room}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const WaitingForThirdPartyRoomView: React.FC<Props> = ({ roomView, resize
<div className="mx_RoomView mx_RoomView--local">
<ErrorBoundary>
{SettingsStore.getValue("feature_new_room_decoration_ui") ? (
<RoomHeader room={context.room} />
<RoomHeader room={context.room!} />
) : (
<LegacyRoomHeader
room={context.room}
Expand Down
12 changes: 3 additions & 9 deletions src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ import React from "react";
import { Body as BodyText } from "@vector-im/compound-web";

import type { Room } from "matrix-js-sdk/src/models/room";
import { IOOBData } from "../../../stores/ThreepidInviteStore";
import { useRoomName } from "../../../hooks/useRoomName";
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import { useTopic } from "../../../hooks/room/useTopic";
import RoomAvatar from "../avatars/RoomAvatar";

export default function RoomHeader({ room, oobData }: { room?: Room; oobData?: IOOBData }): JSX.Element {
const roomName = useRoomName(room, oobData);
export default function RoomHeader({ room }: { room: Room }): JSX.Element {
const roomName = useRoomName(room);
const roomTopic = useTopic(room);

return (
Expand All @@ -40,11 +38,7 @@ export default function RoomHeader({ room, oobData }: { room?: Room; oobData?: I
: rightPanel.setCard({ phase: RightPanelPhases.RoomSummary });
}}
>
{room ? (
<DecoratedRoomAvatar room={room} oobData={oobData} avatarSize={40} displayBadge={false} />
) : (
<RoomAvatar oobData={oobData} width={40} height={40} />
)}
<DecoratedRoomAvatar room={room} avatarSize={40} displayBadge={false} />
<div className="mx_RoomHeader_info">
<BodyText
as="div"
Expand Down
17 changes: 0 additions & 17 deletions test/components/views/rooms/RoomHeader-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,11 @@ describe("Roomeader", () => {
setCardSpy = jest.spyOn(RightPanelStore.instance, "setCard");
});

it("renders with no props", () => {
const { asFragment } = render(<RoomHeader />);
expect(asFragment()).toMatchSnapshot();
});

it("renders the room header", () => {
const { container } = render(<RoomHeader room={room} />);
expect(container).toHaveTextContent(ROOM_ID);
});

it("display the out-of-band room name", () => {
const OOB_NAME = "My private room";
const { container } = render(
<RoomHeader
oobData={{
name: OOB_NAME,
}}
/>,
);
expect(container).toHaveTextContent(OOB_NAME);
});

it("renders the room topic", async () => {
const TOPIC = "Hello World!";

Expand Down

This file was deleted.

Loading