diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index dbd51725..c650d55e 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -688,6 +688,11 @@ export const RoomInput = forwardRef( body, }; + /** + * the currently with the room associated per-message profile, if any, so that it can be included in the message content when sending. + * This allows the server to apply the correct profile-based transformations (e.g. font size adjustments) when processing the message, + * and also allows clients to display an accurate preview of how the message will look with the profile applied while it's being composed. + */ const perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId); if (perMessageProfile) { diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 97597ad4..0385c7d0 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -380,6 +380,11 @@ function MessageInternal( const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); + /** + * We read the per-message profile from the event content here. + * We have to do this in the message component because the per-message profile can be different for each message, and we need to read it for each message individually. + * We also want to avoid reading and parsing the per-message profile in a parent component like the timeline, because that would be inefficient and would cause unnecessary re-renders of the entire timeline whenever a per-message profile changes. + */ const pmp: PerMessageProfileBeeperFormat | undefined = useMemo( () => mEvent.event.content?.['com.beeper.per_message_profile'] as