From daa0015fbd4ae8be17baa5f39265f0f89159f4bf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Aug 2021 15:51:57 +0530 Subject: [PATCH] fixed bridge reply formatting --- src/app/molecules/message/Message.jsx | 5 +---- src/app/organisms/channel/ChannelViewContent.jsx | 10 ++++------ src/app/organisms/channel/common.jsx | 11 +++++++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index 647b672..1b4b3b6 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -86,9 +86,7 @@ MessageHeader.propTypes = { time: PropTypes.string.isRequired, }; -function MessageReply({ - userId, name, color, content, -}) { +function MessageReply({ name, color, content }) { return (
@@ -101,7 +99,6 @@ function MessageReply({ } MessageReply.propTypes = { - userId: PropTypes.string.isRequired, name: PropTypes.string.isRequired, color: PropTypes.string.isRequired, content: PropTypes.string.isRequired, diff --git a/src/app/organisms/channel/ChannelViewContent.jsx b/src/app/organisms/channel/ChannelViewContent.jsx index fa21897..276f55e 100644 --- a/src/app/organisms/channel/ChannelViewContent.jsx +++ b/src/app/organisms/channel/ChannelViewContent.jsx @@ -205,13 +205,12 @@ function genMessage(roomId, prevMEvent, mEvent, roomTimeline, viewEvent) { if (isReply) { const parsedContent = parseReply(content); - if (parsedContent !== null) { - const username = getUsername(parsedContent.userId); + const c = roomTimeline.room.currentState; + const ID = parsedContent.userId || c.getUserIdsWithDisplayName(parsedContent.displayName)[0]; reply = { - userId: parsedContent.userId, - color: colorMXID(parsedContent.userId), - to: username, + color: colorMXID(ID || parsedContent.displayName), + to: parsedContent.displayName || getUsername(parsedContent.userId), content: parsedContent.replyContent, }; content = parsedContent.content; @@ -284,7 +283,6 @@ function genMessage(roomId, prevMEvent, mEvent, roomTimeline, viewEvent) { ); const userReply = reply === null ? null : ( ') !== 0) return null; - let content = rawContent.slice(rawContent.indexOf('@')); - const userId = content.slice(0, content.indexOf('>')); + let content = rawContent.slice(rawContent.indexOf('<') + 1); + const user = content.slice(0, content.indexOf('>')); content = content.slice(content.indexOf('>') + 2); const replyContent = content.slice(0, content.indexOf('\n\n')); content = content.slice(content.indexOf('\n\n') + 2); - if (userId === '') return null; + if (user === '') return null; + + const isUserId = user.match(/^@.+:.+/); return { - userId, + userId: isUserId ? user : null, + displayName: isUserId ? null : user, replyContent, content, };