From 7aee1f07f1b5df66d21973fa0b3a0eb82fa5db2b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 15 May 2026 14:39:16 -0400 Subject: [PATCH] fix: show deletion reason as primary text on redacted messages --- src/app/components/message/MsgTypeRenderers.tsx | 5 ++--- .../message/content/FallbackContent.tsx | 10 ++++------ src/app/features/room/RoomTimeline.tsx | 15 +-------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 668073c36..fe1806018 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -40,12 +40,11 @@ export function MBadEncrypted() { type RedactedContentProps = { reason?: string; - originalBody?: string; }; -export function RedactedContent({ reason, originalBody }: RedactedContentProps) { +export function RedactedContent({ reason }: RedactedContentProps) { return ( - + ); } diff --git a/src/app/components/message/content/FallbackContent.tsx b/src/app/components/message/content/FallbackContent.tsx index aded32834..56665a4af 100644 --- a/src/app/components/message/content/FallbackContent.tsx +++ b/src/app/components/message/content/FallbackContent.tsx @@ -4,14 +4,12 @@ import React from 'react'; const warningStyle = { color: color.Warning.Main, opacity: config.opacity.P300 }; const criticalStyle = { color: color.Critical.Main, opacity: config.opacity.P300 }; -export const MessageDeletedContent = as<'div', { children?: never; reason?: string; originalBody?: string }>( - ({ reason, originalBody, ...props }, ref) => ( +export const MessageDeletedContent = as<'div', { children?: never; reason?: string }>( + ({ reason, ...props }, ref) => ( - {originalBody ? ( - {originalBody.length > 80 ? `${originalBody.slice(0, 80)}…` : originalBody} - ) : reason ? ( - This message has been deleted. {reason} + {reason ? ( + {reason} ) : ( This message has been deleted )} diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 185175627..4e29b9908 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -506,8 +506,6 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli smooth: true, }); - const redactedBodyCache = useRef>(new Map()); - const [focusItem, setFocusItem] = useState< | { index: number; @@ -1037,14 +1035,6 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli const getContent = (() => editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent()) as GetContentCallback; - // Cache body before it can be stripped by redaction - if (!mEvent.isRedacted()) { - const c = mEvent.getContent(); - if (c.body && ['m.text', 'm.notice', 'm.emote'].includes(c.msgtype ?? '')) { - redactedBodyCache.current.set(mEventId, c.body); - } - } - const senderId = mEvent.getSender() ?? ''; const senderDisplayName = getMemberDisplayName(room, senderId) ?? getMxIdLocalPart(senderId) ?? senderId; @@ -1106,10 +1096,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli dateFormatString={dateFormatString} > {mEvent.isRedacted() ? ( - + ) : (