From aff02885def8e0ccf8ae4e5118754dfd6de26bfd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 11:21:21 -0600 Subject: [PATCH] Don't fail if an event doesn't belong to a room. Signed-off-by: Travis Ralston --- src/components/views/rooms/PinnedEventsPanel.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/PinnedEventsPanel.js b/src/components/views/rooms/PinnedEventsPanel.js index fba0d8282..7454e1044 100644 --- a/src/components/views/rooms/PinnedEventsPanel.js +++ b/src/components/views/rooms/PinnedEventsPanel.js @@ -120,11 +120,16 @@ module.exports = React.createClass({ pinnedEvents.getContent().pinned.map(eventId => { promises.push(cli.getEventTimeline(this.props.room.getUnfilteredTimelineSet(), eventId, 0).then(timeline => { return {eventId, timeline}; + }).catch(err => { + console.error("Error looking up pinned event " + eventId + " in room " + this.props.room.roomId); + console.error(err); + return null; // return lack of context to avoid unhandled errors })); }); Promise.all(promises).then(contexts => { - this.setState({ loading: false, pinned: contexts }); + // Filter out the contexts that may have failed early by doing a truthy test + this.setState({ loading: false, pinned: contexts.filter(c => c) }); }); } },