From 5bb15b1002d978715e39fe8e7072530830456c13 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 29 Apr 2018 00:48:44 +0100 Subject: [PATCH] simplify logic Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index b2ea8a90a3..0e9c96f908 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -83,13 +83,8 @@ export default class ReplyThread extends React.Component { async initialize() { const {parentEv} = this.props; - const inReplyTo = ReplyThread.getParentEventId(parentEv); - if (!inReplyTo) { - this.setState({err: true}); - return; - } - - const ev = await ReplyThread.getEvent(this.room, inReplyTo['event_id']); + // at time of making this component we checked that props.parentEv has a parentEventId + const ev = await ReplyThread.getEvent(this.room, ReplyThread.getParentEventId(parentEv)); if (this.unmounted) return; if (ev) { @@ -104,16 +99,16 @@ export default class ReplyThread extends React.Component { async loadNextEvent() { if (this.unmounted) return; const ev = this.state.events[0]; - const inReplyTo = ReplyThread.getParentEventId(ev); + const inReplyToEventId = ReplyThread.getParentEventId(ev); - if (!inReplyTo) { + if (!inReplyToEventId) { this.setState({ loading: false, }); return; } - const loadedEv = await ReplyThread.getEvent(this.room, inReplyTo['event_id']); + const loadedEv = await ReplyThread.getEvent(this.room, inReplyToEventId); if (this.unmounted) return; if (loadedEv) {