Skip to content
Closed
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ export interface CustomComponentsApi {
*
* @param eventType - The event type this renderer is for. Use a RegExp instance if you want to target multiple types.
* @param renderer - The render function.
* @example
* ```
* customComponents.registerMessageRenderer("m.room.message", (props, originalComponent) => {
* return <YourCustomComponent mxEvent={props.mxEvent} />;
* });
* customComponents.registerMessageRenderer(/m\.room\.(topic|name)/, (props, originalComponent) => {
* return <YourCustomStateRenderer mxEvent={props.mxEvent} />;
* });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the API distinct state vs not rather than being quite foot-gunny such that if the latter sees an m.room.name timeline event it'd render it?

Copy link
Member Author

@Half-Shot Half-Shot Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we could tighten up this example. I don't think we need a separate function for state, it's generally good practice within matrix to be checking state keys.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the spirit of the ongoing MVVM work I'd also be keen on simplifying the interface passed, passing entire js-sdk objects around is quite brittle and given we're in the talks of swapping out the js-sdk for the rust-sdk would be guaranteed to break

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what we can do here for the short term, to be honest. I feel like trying to factor MatrixEvent into some sort of common structure is going to have a slight performance overhead per event, and it just feels gross to maintain another structure that we'd have to keep in line with changes to the event structure.

I don't know about the rest of product here but I'd be more in favor of just having a breaking change when the rust-sdk pieces land to support whatever comes next.

* ```
*/
registerMessageRenderer(eventType: string | RegExp, renderer: CustomMessageRenderFunction): void;
}
Loading