@@ -10,6 +10,7 @@ import { type RoomViewProps, type BuiltinsApi } from "@element-hq/element-web-mo
1010
1111import { MatrixClientPeg } from "../MatrixClientPeg" ;
1212import type { Room } from "matrix-js-sdk/src/matrix" ;
13+ import type { ModuleNotificationDecorationProps } from "./components/ModuleNotificationDecoration" ;
1314
1415interface RoomViewPropsWithRoomId extends RoomViewProps {
1516 /**
@@ -26,11 +27,14 @@ interface RoomAvatarProps {
2627interface Components {
2728 roomView : React . ComponentType < RoomViewPropsWithRoomId > ;
2829 roomAvatar : React . ComponentType < RoomAvatarProps > ;
30+ notificationDecoration : React . ComponentType < ModuleNotificationDecorationProps > ;
2931}
3032
3133export class ElementWebBuiltinsApi implements BuiltinsApi {
3234 private _roomView ?: Components [ "roomView" ] ;
3335 private _roomAvatar ?: Components [ "roomAvatar" ] ;
36+ private _notificationDecoration ?: Components [ "notificationDecoration" ] ;
37+
3438 /**
3539 * Sets the components used by the API.
3640 *
@@ -43,24 +47,30 @@ export class ElementWebBuiltinsApi implements BuiltinsApi {
4347 public setComponents ( components : Components ) : void {
4448 this . _roomView = components . roomView ;
4549 this . _roomAvatar = components . roomAvatar ;
50+ this . _notificationDecoration = components . notificationDecoration ;
4651 }
4752
4853 public getRoomViewComponent ( ) : React . ComponentType < RoomViewPropsWithRoomId > {
4954 if ( ! this . _roomView ) {
5055 throw new Error ( "No RoomView component has been set" ) ;
5156 }
52-
5357 return this . _roomView ;
5458 }
5559
5660 public getRoomAvatarComponent ( ) : React . ComponentType < RoomAvatarProps > {
5761 if ( ! this . _roomAvatar ) {
5862 throw new Error ( "No RoomAvatar component has been set" ) ;
5963 }
60-
6164 return this . _roomAvatar ;
6265 }
6366
67+ public getNotificationDecorationComponent ( ) : React . ComponentType < ModuleNotificationDecorationProps > {
68+ if ( ! this . _notificationDecoration ) {
69+ throw new Error ( "No NotificationDecoration component has been set" ) ;
70+ }
71+ return this . _notificationDecoration ;
72+ }
73+
6474 public renderRoomView ( roomId : string , props ?: RoomViewProps ) : React . ReactNode {
6575 const Component = this . getRoomViewComponent ( ) ;
6676 return < Component roomId = { roomId } { ...props } /> ;
@@ -74,4 +84,13 @@ export class ElementWebBuiltinsApi implements BuiltinsApi {
7484 const Component = this . getRoomAvatarComponent ( ) ;
7585 return < Component room = { room } size = { size } /> ;
7686 }
87+
88+ public renderNotificationDecoration ( roomId : string ) : React . ReactNode {
89+ const room = MatrixClientPeg . safeGet ( ) . getRoom ( roomId ) ;
90+ if ( ! room ) {
91+ throw new Error ( `No room such room: ${ roomId } ` ) ;
92+ }
93+ const Component = this . getNotificationDecorationComponent ( ) ;
94+ return < Component room = { room } /> ;
95+ }
7796}
0 commit comments