Skip to content
Draft
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
19 changes: 15 additions & 4 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import { debounce, throttle } from "lodash";
import { CryptoEvent } from "matrix-js-sdk/src/crypto-api";
import { type ViewRoomOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle";
import { type RoomViewProps } from "@element-hq/element-web-module-api";

Check failure on line 47 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Module '"@element-hq/element-web-module-api"' has no exported member 'RoomViewProps'.

import shouldHideEvent from "../../shouldHideEvent";
import { _t } from "../../languageHandler";
Expand Down Expand Up @@ -159,6 +159,14 @@

// Called with the credentials of a registered user (if they were a ROU that transitioned to PWLU)
onRegistered?(credentials: IMatrixClientCreds): void;
/*
* If true, hide the header
*/
hideHeader?: boolean;
/*
* If true, hide the composer
*/
hideComposer?: boolean;
}

export { MainSplitContentType };
Expand Down Expand Up @@ -396,8 +404,8 @@
throw new Error("Unable to create RoomView without MatrixClient");
}

if (props.roomId) {

Check failure on line 407 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'roomId' does not exist on type 'IRoomProps'.
this.roomViewStore = this.context.multiRoomViewStore.getRoomViewStoreForRoom(props.roomId);

Check failure on line 408 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'roomId' does not exist on type 'IRoomProps'.
} else {
this.roomViewStore = context.roomViewStore;
}
Expand Down Expand Up @@ -1041,7 +1049,7 @@
this.context.client?.store.removeRoom(this.state.room.roomId);
}

if (this.props.roomId) this.context.multiRoomViewStore.removeRoomViewStore(this.props.roomId);

Check failure on line 1052 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'roomId' does not exist on type 'Readonly<IRoomProps>'.

Check failure on line 1052 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'roomId' does not exist on type 'Readonly<IRoomProps>'.
}

private onRightPanelStoreUpdate = (): void => {
Expand Down Expand Up @@ -2439,6 +2447,7 @@

let messageComposer;
const showComposer =
!this.props.hideComposer &&
!isRoomEncryptionLoading &&
// joined and not showing search results
myMembership === KnownMembership.Join &&
Expand Down Expand Up @@ -2649,10 +2658,12 @@
ref={this.roomViewBody}
data-layout={this.state.layout}
>
<RoomHeader
room={this.state.room}
additionalButtons={this.state.viewRoomOpts.buttons}
/>
{!this.props.hideHeader && (
<RoomHeader
room={this.state.room}
additionalButtons={this.state.viewRoomOpts.buttons}
/>
)}
{mainSplitBody}
</div>
</MainSplit>
Expand Down
17 changes: 12 additions & 5 deletions src/modules/BuiltinsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
*/

import React from "react";
import { type RoomViewProps, type BuiltinsApi } from "@element-hq/element-web-module-api";

Check failure on line 9 in src/modules/BuiltinsApi.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Module '"@element-hq/element-web-module-api"' has no exported member 'RoomViewProps'.

import RoomAvatar from "../components/views/avatars/RoomAvatar";
import { getSafeCli } from "./common";

interface RoomViewPropsWithRoomId extends RoomViewProps {
/**
* The ID of the room to display
*/
roomId: string;
}

export class ElementWebBuiltinsApi implements BuiltinsApi {
private _roomView?: React.ComponentType<RoomViewProps>;
private _roomView?: React.ComponentType<RoomViewPropsWithRoomId>;

/**
* Sets the components used to render a RoomView
Expand All @@ -23,21 +30,21 @@
*
* @param component The RoomView component
*/
public setRoomViewComponent(component: React.ComponentType<RoomViewProps>): void {
public setRoomViewComponent(component: React.ComponentType<RoomViewPropsWithRoomId>): void {
this._roomView = component;
}

public getRoomViewComponent(): React.ComponentType<RoomViewProps> {
public getRoomViewComponent(): React.ComponentType<RoomViewPropsWithRoomId> {
if (!this._roomView) {
throw new Error("No RoomView component has been set");
}

return this._roomView;
}

public renderRoomView(roomId: string): React.ReactNode {
public renderRoomView(roomId: string, props?: RoomViewProps): React.ReactNode {
const Component = this.getRoomViewComponent();
return <Component roomId={roomId} />;
return <Component roomId={roomId} {...props} />;
}

public renderRoomAvatar(roomId: string, size?: string): React.ReactNode {
Expand Down
Loading