diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index ba0a5fd4..37c0c0d5 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -3,7 +3,6 @@ import { KeyboardEventHandler, MouseEvent, RefObject, - ReactNode, useCallback, useEffect, useRef, @@ -44,13 +43,6 @@ import { toRem, } from 'folds'; -import parse from 'html-react-parser'; -import { - getReactCustomHtmlParser, - LINKIFY_OPTS, - scaleSystemEmoji, -} from '$plugins/react-custom-html-parser'; - import { useMatrixClient } from '$hooks/useMatrixClient'; import { AutocompletePrefix, @@ -83,7 +75,6 @@ import { TUploadContent, encryptFile, getImageInfo, - getMxIdLocalPart, mxcUrlToHttp, toggleReaction, } from '$utils/matrix'; @@ -113,23 +104,16 @@ import { safeFile } from '$utils/mimeTypes'; import { fulfilledPromiseSettledResult } from '$utils/common'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; -import { - getMemberDisplayName, - getMentionContent, - reactionOrEditEvent, - trimReplyFromBody, - trimReplyFromFormattedBody, -} from '$utils/room'; +import { getMentionContent, reactionOrEditEvent } from '$utils/room'; import { Command, SHRUG, TABLEFLIP, UNFLIP, useCommands } from '$hooks/useCommands'; import { mobileOrTablet } from '$utils/user-agent'; import { useElementSizeObserver } from '$hooks/useElementSizeObserver'; -import { ReplyLayout, ThreadIndicator } from '$components/message'; +import { Reply, ThreadIndicator } from '$components/message'; import { roomToParentsAtom } from '$state/room/roomToParents'; import { nicknamesAtom } from '$state/nicknames'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useImagePackRooms } from '$hooks/useImagePackRooms'; import { useComposingCheck } from '$hooks/useComposingCheck'; -import { useSableCosmetics } from '$hooks/useSableCosmetics'; import { createLogger } from '$utils/debug'; import { createDebugLogger } from '$utils/debugLogger'; import FocusTrap from 'focus-trap-react'; @@ -275,12 +259,6 @@ export const RoomInput = forwardRef( const [msgDraft, setMsgDraft] = useAtom(roomIdToMsgDraftAtomFamily(draftKey)); const [replyDraft, setReplyDraft] = useAtom(roomIdToReplyDraftAtomFamily(draftKey)); - const replyUserID = replyDraft?.userId; - - const { color: replyUsernameColor, font: replyUsernameFont } = useSableCosmetics( - replyUserID ?? '', - room - ); const [uploadBoard, setUploadBoard] = useState(true); const [selectedFiles, setSelectedFiles] = useAtom(roomIdToUploadItemsAtomFamily(draftKey)); @@ -373,45 +351,6 @@ export const RoomInput = forwardRef( ); const replyEvent = replyDraft ? room.findEventById(replyDraft.eventId) : undefined; - const { - body: replyBody, - formatted_body: replyFormattedBody, - format: replyFormat, - } = replyEvent?.getContent() ?? {}; - - // Prefer the live event content; fall back to what was snapshotted in the - // draft when the user hit Reply (the event may not be in SDK state if it - // was redacted or evicted, but the draft always carries the original body). - const htmlBody = - replyFormat === 'org.matrix.custom.html' ? replyFormattedBody : replyDraft?.formattedBody; - const plainBody = replyBody ?? replyDraft?.body; - - let replyBodyJSX: ReactNode = replyDraft ? trimReplyFromBody(replyDraft.body) : null; - - if (htmlBody) { - /** - * message with linebreaks, etc stripped - */ - const strippedHtml = trimReplyFromFormattedBody(htmlBody) - .replaceAll(//gi, ' ') - .replaceAll(/<\/p>\s*]*>/gi, ' ') - .replaceAll(/<\/?p[^>]*>/gi, '') - .replaceAll(/(?:\r\n|\r|\n)/g, ' ') - .trim(); - const parserOpts = getReactCustomHtmlParser(mx, roomId, { - linkifyOpts: LINKIFY_OPTS, - useAuthentication, - nicknames, - }); - replyBodyJSX = parse(strippedHtml, parserOpts); - } else if (plainBody) { - const strippedBody = trimReplyFromBody(plainBody).replaceAll(/(?:\r\n|\r|\n)/g, ' '); - replyBodyJSX = scaleSystemEmoji(strippedBody); - } - - // Seed the reply draft with the thread relation whenever we're in thread - // mode (e.g. on first render or when the thread root changes). We use the - // current user's ID as userId so that the mention logic skips it. useEffect(() => { if (!threadRootId) return; setReplyDraft((prev) => { @@ -1260,22 +1199,7 @@ export const RoomInput = forwardRef( {replyDraft.relation?.rel_type === RelationType.Thread && !threadRootId && ( )} - - - {getMemberDisplayName(room, replyDraft.userId, nicknames) ?? - getMxIdLocalPart(replyDraft.userId) ?? - replyDraft.userId} - - - } - > - - {replyBodyJSX} - - +