From 6693347c2e8a7e9d9835b2c83836a290bdaa0302 Mon Sep 17 00:00:00 2001 From: Shea Date: Sat, 13 Jun 2026 17:29:27 +0300 Subject: [PATCH] fix more highlighting problems and 1767 events reply setting issues Signed-off-by: Shea --- src/app/features/room/ThreadDrawer.tsx | 8 ++++++- src/app/hooks/timeline/useTimelineActions.ts | 8 ++++++- .../timeline/useTimelineEventRenderer.tsx | 24 +++++++++---------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index b2d05b0cc..7c3cb231a 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -66,6 +66,7 @@ import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollo import * as css from './ThreadDrawer.css'; import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer'; import { mobileOrTablet } from '$utils/user-agent'; +import { M_TEXT } from 'matrix-js-sdk'; /** * Resolve the list of reply events to show in the thread drawer. @@ -574,12 +575,17 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const editedReply = getEditedEvent(replyId, replyEvt, room.getUnfilteredTimelineSet()); const content = editedReply?.getContent()['m.new_content'] ?? replyEvt.getContent(); const { body, formatted_body: formattedBody } = content; + const msc1767body = content[M_TEXT.name]; const senderId = replyEvt.getSender(); if (senderId) { const draft: IReplyDraft = { userId: senderId, eventId: replyId, - body: typeof body === 'string' ? body : '', + body: + (body as string) ?? + (msc1767body as string) ?? + (msc1767body as { body: string }).body ?? + '', formattedBody, relation: { rel_type: RelationType.Thread, event_id: threadRootId }, }; diff --git a/src/app/hooks/timeline/useTimelineActions.ts b/src/app/hooks/timeline/useTimelineActions.ts index c82719411..090125476 100644 --- a/src/app/hooks/timeline/useTimelineActions.ts +++ b/src/app/hooks/timeline/useTimelineActions.ts @@ -10,6 +10,7 @@ import { getMxIdLocalPart, toggleReaction } from '$utils/matrix'; import { getMemberDisplayName, getEditedEvent } from '$utils/room'; import { createMentionElement, moveCursor } from '$components/editor'; import * as prefix from '$unstable/prefixes'; +import { M_TEXT } from 'matrix-js-sdk'; export interface UseTimelineActionsOptions { room: Room; @@ -144,6 +145,7 @@ export function useTimelineActions({ const content: IContent = (editedNewContent ?? replyEvt.getContent()) as IContent; const { body, formatted_body: formattedBody } = content; + const msc1767body = content[M_TEXT.name]; const { 'm.relates_to': relation } = startThread ? { 'm.relates_to': { rel_type: 'm.thread', event_id: replyId } } @@ -155,7 +157,11 @@ export function useTimelineActions({ setReplyDraft({ userId: senderId, eventId: replyId, - body: typeof body === 'string' ? body : '', + body: + (body as string) ?? + (msc1767body as string) ?? + (msc1767body as { body: string }).body ?? + '', formattedBody: typeof formattedBody === 'string' ? formattedBody : '', relation, }); diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx index 879fbc907..9213e16f7 100644 --- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx +++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx @@ -378,7 +378,7 @@ export function useTimelineEventRenderer({ const reactions = reactionRelations?.getSortedAnnotationsByKey(); const hasReactions = reactions && reactions.length > 0; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId && suppressMark !== true; + const marked = activeReplyId === mEventId && !suppressMark; const pushActions = pushProcessor.actionsForEvent(mEvent); let notifyHighlight: 'silent' | 'loud' | undefined; @@ -542,7 +542,7 @@ export function useTimelineEventRenderer({ const reactions = reactionRelations?.getSortedAnnotationsByKey(); const hasReactions = reactions && reactions.length > 0; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderDisplayName = getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId; @@ -720,7 +720,7 @@ export function useTimelineEventRenderer({ const reactions = reactionRelations?.getSortedAnnotationsByKey(); const hasReactions = reactions && reactions.length > 0; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderDisplayName = getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId; @@ -845,7 +845,7 @@ export function useTimelineEventRenderer({ const reactions = reactionRelations?.getSortedAnnotationsByKey(); const hasReactions = reactions && reactions.length > 0; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const pushActions = pushProcessor.actionsForEvent(mEvent); let notifyHighlight: 'silent' | 'loud' | undefined; @@ -999,7 +999,7 @@ export function useTimelineEventRenderer({ if (!membershipChanged && hideNickAvatarEvents) return null; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const parsed = parseMemberEvent(mEvent); const timeJSX = ( @@ -1044,7 +1044,7 @@ export function useTimelineEventRenderer({ }, [EventType.RoomName]: (mEventId, mEvent, item, timelineSet, collapse) => { const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); @@ -1091,7 +1091,7 @@ export function useTimelineEventRenderer({ }, [EventType.RoomTopic]: (mEventId, mEvent, item, timelineSet, collapse) => { const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); @@ -1139,7 +1139,7 @@ export function useTimelineEventRenderer({ }, [EventType.RoomAvatar]: (mEventId, mEvent, item, timelineSet, collapse) => { const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); @@ -1187,7 +1187,7 @@ export function useTimelineEventRenderer({ }, [EventType.GroupCallMemberPrefix]: (mEventId, mEvent, item, timelineSet, collapse) => { const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId) || getMxIdLocalPart(senderId); @@ -1243,7 +1243,7 @@ export function useTimelineEventRenderer({ [EventType.RoomPinnedEvents]: (mEventId, mEvent, item, timelineSet, collapse) => { if (!showHiddenEvents) return null; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); @@ -1332,7 +1332,7 @@ export function useTimelineEventRenderer({ (mEventId, mEvent, item, timelineSet, collapse) => { if (!showHiddenEvents) return null; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); @@ -1387,7 +1387,7 @@ export function useTimelineEventRenderer({ if (mEvent.isRedaction()) return null; const highlighted = focusItem?.index === item && focusItem.highlight; - const marked = activeReplyId === mEventId; + const marked = activeReplyId === mEventId && !suppressMark; const senderId = mEvent.getSender() ?? ''; const senderName = getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);