From 33657947d39fcf01549b116aec43a45206a2e6c3 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 28 Feb 2022 09:47:14 -0500 Subject: [PATCH] Inject sender into pinned messages (#7904) * Inject sender into pinned messages Signed-off-by: Robin Townsend * Remove unused prop Signed-off-by: Robin Townsend --- src/components/views/right_panel/PinnedMessagesCard.tsx | 3 ++- src/components/views/rooms/PinnedEventTile.tsx | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/views/right_panel/PinnedMessagesCard.tsx b/src/components/views/right_panel/PinnedMessagesCard.tsx index 31fcc27266..7e4bc3a7ae 100644 --- a/src/components/views/right_panel/PinnedMessagesCard.tsx +++ b/src/components/views/right_panel/PinnedMessagesCard.tsx @@ -108,6 +108,8 @@ const PinnedMessagesCard = ({ room, onClose }: IProps) => { await cli.decryptEventIfNeeded(event); // TODO await? } if (event && PinningUtils.isPinnable(event)) { + // Inject sender information + event.sender = room.getMember(event.getSender()); return event; } } catch (err) { @@ -140,7 +142,6 @@ const PinnedMessagesCard = ({ room, onClose }: IProps) => { content = pinnedEvents.filter(Boolean).reverse().map(ev => ( onUnpinClicked(ev) : undefined} /> diff --git a/src/components/views/rooms/PinnedEventTile.tsx b/src/components/views/rooms/PinnedEventTile.tsx index 91ad97236a..7163b27c3f 100644 --- a/src/components/views/rooms/PinnedEventTile.tsx +++ b/src/components/views/rooms/PinnedEventTile.tsx @@ -16,7 +16,6 @@ limitations under the License. */ import React from "react"; -import { Room } from "matrix-js-sdk/src/models/room"; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import dis from "../../../dispatcher/dispatcher"; @@ -33,7 +32,6 @@ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload"; interface IProps { - room: Room; event: MatrixEvent; onUnpinClicked?(): void; } @@ -56,7 +54,6 @@ export default class PinnedEventTile extends React.Component { render() { const sender = this.props.event.getSender(); - const senderProfile = this.props.room.getMember(sender); let unpinButton = null; if (this.props.onUnpinClicked) { @@ -72,14 +69,14 @@ export default class PinnedEventTile extends React.Component { return
- { senderProfile?.name || sender } + { this.props.event.sender?.name || sender } { unpinButton }