Skip to content

Commit f1037d5

Browse files
committed
Add a wrapper component
So that we can render the decoration component with just the room.
1 parent 5cddaa7 commit f1037d5

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2025 Element Creations Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE files in the repository root for full details.
6+
*/
7+
import React, { useMemo } from "react";
8+
9+
import type { Room } from "matrix-js-sdk/src/matrix";
10+
import { RoomNotificationStateStore } from "../../stores/notifications/RoomNotificationStateStore";
11+
import { useCall } from "../../hooks/useCall";
12+
import { NotificationDecoration } from "../../components/views/rooms/NotificationDecoration";
13+
14+
export interface ModuleNotificationDecorationProps {
15+
/**
16+
* The room for which the decoration is rendered.
17+
*/
18+
room: Room;
19+
}
20+
21+
/**
22+
* React component that takes a room as prop and renders {@link NotificationDecoration} with it.
23+
* Used by the module API to render notification decoration without having to expose a bunch of stores.
24+
*/
25+
export const ModuleNotificationDecoration: React.FC<ModuleNotificationDecorationProps> = ({ room }) => {
26+
const notificationState = useMemo(() => RoomNotificationStateStore.instance.getRoomState(room), [room]);
27+
const call = useCall(room.roomId);
28+
return <NotificationDecoration notificationState={notificationState} callType={call?.callType} />;
29+
};

0 commit comments

Comments
 (0)