Add options to hide header and composer of room view for the module api (#31095)
* feat: add props to hide header in `RoomView` * feat: add props to hide composer in `RoomView` * feat: pass `RoomViewProps` to room view in `renderRoomView` * refactor: add doc and use existing types * test: add tests for new room view props
This commit is contained in:
@@ -12,6 +12,9 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import type { Room } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
interface RoomViewPropsWithRoomId extends RoomViewProps {
|
||||
/**
|
||||
* The ID of the room to display
|
||||
*/
|
||||
roomId?: string;
|
||||
}
|
||||
|
||||
@@ -26,9 +29,8 @@ interface Components {
|
||||
}
|
||||
|
||||
export class ElementWebBuiltinsApi implements BuiltinsApi {
|
||||
private _roomView?: React.ComponentType<RoomViewPropsWithRoomId>;
|
||||
private _roomAvatar?: React.ComponentType<RoomAvatarProps>;
|
||||
|
||||
private _roomView?: Components["roomView"];
|
||||
private _roomAvatar?: Components["roomAvatar"];
|
||||
/**
|
||||
* Sets the components used by the API.
|
||||
*
|
||||
@@ -59,9 +61,9 @@ export class ElementWebBuiltinsApi implements BuiltinsApi {
|
||||
return this._roomAvatar;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user