Skip to content

Commit 8bfab91

Browse files
committed
feat: pass RoomViewProps to room view in renderRoomView
1 parent c22250c commit 8bfab91

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/modules/BuiltinsApi.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ import { type RoomViewProps, type BuiltinsApi } from "@element-hq/element-web-mo
1111
import RoomAvatar from "../components/views/avatars/RoomAvatar";
1212
import { getSafeCli } from "./common";
1313

14+
interface RoomViewPropsWithRoomId extends RoomViewProps {
15+
/**
16+
* The ID of the room to display
17+
*/
18+
roomId: string;
19+
}
20+
1421
export class ElementWebBuiltinsApi implements BuiltinsApi {
15-
private _roomView?: React.ComponentType<RoomViewProps>;
22+
private _roomView?: React.ComponentType<RoomViewPropsWithRoomId>;
1623

1724
/**
1825
* Sets the components used to render a RoomView
@@ -23,21 +30,21 @@ export class ElementWebBuiltinsApi implements BuiltinsApi {
2330
*
2431
* @param component The RoomView component
2532
*/
26-
public setRoomViewComponent(component: React.ComponentType<RoomViewProps>): void {
33+
public setRoomViewComponent(component: React.ComponentType<RoomViewPropsWithRoomId>): void {
2734
this._roomView = component;
2835
}
2936

30-
public getRoomViewComponent(): React.ComponentType<RoomViewProps> {
37+
public getRoomViewComponent(): React.ComponentType<RoomViewPropsWithRoomId> {
3138
if (!this._roomView) {
3239
throw new Error("No RoomView component has been set");
3340
}
3441

3542
return this._roomView;
3643
}
3744

38-
public renderRoomView(roomId: string): React.ReactNode {
45+
public renderRoomView(roomId: string, props?: RoomViewProps): React.ReactNode {
3946
const Component = this.getRoomViewComponent();
40-
return <Component roomId={roomId} />;
47+
return <Component roomId={roomId} {...props} />;
4148
}
4249

4350
public renderRoomAvatar(roomId: string, size?: string): React.ReactNode {

0 commit comments

Comments
 (0)