From 29be28919da4dc4f4edb8aa3cab4924f63c01875 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 21 Feb 2019 15:44:20 +0100 Subject: [PATCH] create permalink creator in roomview and pass it on to the event tiles --- src/components/structures/MessagePanel.js | 1 + src/components/structures/RoomView.js | 13 +++++++++++++ src/components/structures/TimelinePanel.js | 1 + src/components/views/rooms/EventTile.js | 6 ++++-- src/components/views/rooms/SearchResultTile.js | 1 + src/matrix-to.js | 6 +++--- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index dd3d92913c..a6c43ecc8e 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -525,6 +525,7 @@ module.exports = React.createClass({ eventSendStatus={mxEv.status} tileShape={this.props.tileShape} isTwelveHour={this.props.isTwelveHour} + permaLinkCreator={this.props.permaLinkCreator} last={last} isSelectedEvent={highlight} /> , ); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 85f3afdfa5..54ef6be558 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -30,6 +30,7 @@ import Promise from 'bluebird'; import filesize from 'filesize'; const classNames = require("classnames"); import { _t } from '../../languageHandler'; +import {RoomPermaLinkCreator} from "../../matrix-to"; const MatrixClientPeg = require("../../MatrixClientPeg"); const ContentMessages = require("../../ContentMessages"); @@ -441,6 +442,11 @@ module.exports = React.createClass({ RoomScrollStateStore.setScrollState(this.state.roomId, this._getScrollState()); } + // stop tracking room changes to format permalinks + if (this.state.permaLinkCreator) { + this.state.permaLinkCreator.stop(); + } + if (this.refs.roomView) { // disconnect the D&D event listeners from the room view. This // is really just for hygiene - we're going to be @@ -652,6 +658,11 @@ module.exports = React.createClass({ this._loadMembersIfJoined(room); this._calculateRecommendedVersion(room); this._updateE2EStatus(room); + if (!this.state.permaLinkCreator) { + const permaLinkCreator = new RoomPermaLinkCreator(room); + permaLinkCreator.start(); + this.setState({permaLinkCreator}); + } }, _calculateRecommendedVersion: async function(room) { @@ -1219,6 +1230,7 @@ module.exports = React.createClass({ searchResult={result} searchHighlights={this.state.searchHighlights} resultLink={resultLink} + permaLinkCreator={this.state.permaLinkCreator} onWidgetLoad={onWidgetLoad} />); } return ret; @@ -1826,6 +1838,7 @@ module.exports = React.createClass({ showUrlPreview = {this.state.showUrlPreview} className="mx_RoomView_messagePanel" membersLoaded={this.state.membersLoaded} + permaLinkCreator={this.state.permaLinkCreator} />); let topUnreadMessagesBar = null; diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 9fe83c2c2d..1dc9162ef1 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -1202,6 +1202,7 @@ var TimelinePanel = React.createClass({ return (