From 3ba9f560d44b2c62998f2cc85c1494bf76bfa3ff Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 27 Apr 2018 11:30:47 +0100 Subject: [PATCH] get MatrixClient from context Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index ed284c1da2..51cb53efea 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -18,9 +18,8 @@ import sdk from '../../../index'; import {_t} from '../../../languageHandler'; import PropTypes from 'prop-types'; import dis from '../../../dispatcher'; -import MatrixClientPeg from '../../../MatrixClientPeg'; import {wantsDateSeparator} from '../../../DateUtils'; -import {MatrixEvent} from 'matrix-js-sdk'; +import {MatrixEvent, MatrixClient} from 'matrix-js-sdk'; import {makeEventPermalink, makeUserPermalink} from "../../../matrix-to"; import SettingsStore from "../../../settings/SettingsStore"; @@ -35,6 +34,10 @@ export default class ReplyThread extends React.Component { onWidgetLoad: PropTypes.func.isRequired, }; + static contextTypes = { + matrixClient: PropTypes.instanceOf(MatrixClient).isRequired, + }; + constructor(props, context) { super(props, context); @@ -58,7 +61,7 @@ export default class ReplyThread extends React.Component { componentWillMount() { this.unmounted = false; - this.room = MatrixClientPeg.get().getRoom(this.props.parentEv.getRoomId()); + this.room = this.context.matrixClient.getRoom(this.props.parentEv.getRoomId()); this.initialize(); } @@ -121,7 +124,7 @@ export default class ReplyThread extends React.Component { if (event) return event; try { - await MatrixClientPeg.get().getEventTimeline(room.getUnfilteredTimelineSet(), eventId); + await this.context.matrixClient.getEventTimeline(room.getUnfilteredTimelineSet(), eventId); } catch (e) { return null; } @@ -257,7 +260,7 @@ export default class ReplyThread extends React.Component { } else if (this.state.loadedEv) { const ev = this.state.loadedEv; const Pill = sdk.getComponent('elements.Pill'); - const room = MatrixClientPeg.get().getRoom(ev.getRoomId()); + const room = this.context.matrixClient.getRoom(ev.getRoomId()); header =
{ _t('In reply to', {}, {