From 97d344483ebec8f622a211c435c6b75686f5fd29 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 3 May 2018 14:32:13 +0100 Subject: [PATCH] fix thinko when changing from ClientPeg to context in static method (DUH Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index c7ca4b2d41..cd444fb090 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -59,22 +59,6 @@ export default class ReplyThread extends React.Component { this.collapse = this.collapse.bind(this); } - static async getEvent(room, eventId) { - const event = room.findEventById(eventId); - if (event) return event; - - try { - // ask the client to fetch the event we want using the context API, only interface to do so is to ask - // for a timeline with that event, but once it is loaded we can use findEventById to look up the ev map - await this.context.matrixClient.getEventTimeline(room.getUnfilteredTimelineSet(), eventId); - } catch (e) { - // if it fails catch the error and return early, there's no point trying to find the event in this case. - // Return null as it is falsey and thus should be treated as an error (as the event cannot be resolved). - return null; - } - return room.findEventById(eventId); - } - static getParentEventId(ev) { if (!ev || ev.isRedacted()) return; @@ -199,7 +183,7 @@ export default class ReplyThread extends React.Component { async initialize() { const {parentEv} = this.props; // at time of making this component we checked that props.parentEv has a parentEventId - const ev = await ReplyThread.getEvent(this.room, ReplyThread.getParentEventId(parentEv)); + const ev = await this.getEvent(ReplyThread.getParentEventId(parentEv)); if (this.unmounted) return; if (ev) { @@ -223,7 +207,7 @@ export default class ReplyThread extends React.Component { return; } - const loadedEv = await ReplyThread.getEvent(this.room, inReplyToEventId); + const loadedEv = await this.getEvent(inReplyToEventId); if (this.unmounted) return; if (loadedEv) { @@ -233,6 +217,22 @@ export default class ReplyThread extends React.Component { } } + async getEvent(eventId) { + const event = this.room.findEventById(eventId); + if (event) return event; + + try { + // ask the client to fetch the event we want using the context API, only interface to do so is to ask + // for a timeline with that event, but once it is loaded we can use findEventById to look up the ev map + await this.context.matrixClient.getEventTimeline(this.room.getUnfilteredTimelineSet(), eventId); + } catch (e) { + // if it fails catch the error and return early, there's no point trying to find the event in this case. + // Return null as it is falsey and thus should be treated as an error (as the event cannot be resolved). + return null; + } + return this.room.findEventById(eventId); + } + canCollapse() { return this.state.events.length > 1; }