From fb672ffb2822cc668039e0099eb32f97fa12e1c5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 25 Feb 2019 16:08:07 +0100 Subject: [PATCH] change handling of event permalinks in replies --- src/components/structures/RoomView.js | 1 + src/components/views/elements/ReplyThread.js | 13 ++++++++----- src/components/views/rooms/EventTile.js | 2 +- src/components/views/rooms/MessageComposer.js | 3 ++- src/components/views/rooms/MessageComposerInput.js | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index d1b932a202..8d55715dbf 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1737,6 +1737,7 @@ module.exports = React.createClass({ showApps={this.state.showApps} uploadAllowed={this.isFileUploadAllowed} e2eStatus={this.state.e2eStatus} + permalinkCreator={this.state.permalinkCreator} />; } diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index f9f3f4ca97..e7dc020245 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -20,7 +20,7 @@ import PropTypes from 'prop-types'; import dis from '../../../dispatcher'; import {wantsDateSeparator} from '../../../DateUtils'; import {MatrixEvent, MatrixClient} from 'matrix-js-sdk'; -import {makeEventPermalink, makeUserPermalink} from "../../../matrix-to"; +import {makeUserPermalink} from "../../../matrix-to"; import SettingsStore from "../../../settings/SettingsStore"; // This component does no cycle detection, simply because the only way to make such a cycle would be to @@ -32,6 +32,7 @@ export default class ReplyThread extends React.Component { parentEv: PropTypes.instanceOf(MatrixEvent), // called when the ReplyThread contents has changed, including EventTiles thereof onWidgetLoad: PropTypes.func.isRequired, + permalinkCreator: PropTypes.object.isRequired, }; static contextTypes = { @@ -85,7 +86,7 @@ export default class ReplyThread extends React.Component { } // Part of Replies fallback support - static getNestedReplyText(ev) { + static getNestedReplyText(ev, permalinkCreator) { if (!ev) return null; let {body, formatted_body: html} = ev.getContent(); @@ -94,7 +95,7 @@ export default class ReplyThread extends React.Component { if (html) html = this.stripHTMLReply(html); } - const evLink = makeEventPermalink(ev.getRoomId(), ev.getId()); + const evLink = permalinkCreator.forEvent(ev.getId()); const userLink = makeUserPermalink(ev.getSender()); const mxid = ev.getSender(); @@ -159,11 +160,12 @@ export default class ReplyThread extends React.Component { }; } - static makeThread(parentEv, onWidgetLoad, ref) { + static makeThread(parentEv, onWidgetLoad, permalinkCreator, ref) { if (!ReplyThread.getParentEventId(parentEv)) { return
; } - return ; + return ; } componentWillMount() { @@ -294,6 +296,7 @@ export default class ReplyThread extends React.Component { ; }); diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 17d272fa36..8a2f7802d6 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -735,7 +735,7 @@ module.exports = withMatrixClient(React.createClass({ { timestamp } { this._renderE2EPadlock() } - { ReplyThread.makeThread(this.props.mxEvent, this.props.onWidgetLoad, 'replyThread') } + { ReplyThread.makeThread(this.props.mxEvent, this.props.onWidgetLoad, this.props.permalinkCreator, 'replyThread') } , + onInputStateChanged={this.onInputStateChanged} + permalinkCreator={this.props.permalinkCreator} />, formattingButton, stickerpickerButton, uploadButton, diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index d64f8195cd..5ad09d1fa8 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -1195,7 +1195,7 @@ export default class MessageComposerInput extends React.Component { // Part of Replies fallback support - prepend the text we're sending // with the text we're replying to - const nestedReply = ReplyThread.getNestedReplyText(replyingToEv); + const nestedReply = ReplyThread.getNestedReplyText(replyingToEv, this.props.permalinkCreator); if (nestedReply) { if (content.formatted_body) { content.formatted_body = nestedReply.html + content.formatted_body;