From ac23afe9f1a8f4396a34ade5d3dfa6995682c810 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Fri, 15 Oct 2021 15:36:06 +0100 Subject: [PATCH] Allow EventTile to be rendered with mock events --- src/components/views/rooms/EventTile.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index 44bf500f50..8a50284a93 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -478,7 +478,7 @@ export default class EventTile extends React.Component { } const room = this.context.getRoom(this.props.mxEvent.getRoomId()); - room.on(ThreadEvent.New, this.onNewThread); + room?.on(ThreadEvent.New, this.onNewThread); } private updateThread = (thread) => { @@ -522,7 +522,7 @@ export default class EventTile extends React.Component { } const room = this.context.getRoom(this.props.mxEvent.getRoomId()); - room.off(ThreadEvent.New, this.onNewThread); + room?.off(ThreadEvent.New, this.onNewThread); } componentDidUpdate(prevProps, prevState, snapshot) { @@ -553,7 +553,7 @@ export default class EventTile extends React.Component { * when we are at the sync stage */ const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); - const thread = room.threads.get(this.props.mxEvent.getId()); + const thread = room?.threads.get(this.props.mxEvent.getId()); if (thread && !thread.ready) { thread.addEvent(this.props.mxEvent, true);