Don't fail if an event doesn't belong to a room.

Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
Travis Ralston 2017-09-29 11:21:21 -06:00
parent 965a25ba84
commit aff02885de

View File

@ -120,11 +120,16 @@ module.exports = React.createClass({
pinnedEvents.getContent().pinned.map(eventId => { pinnedEvents.getContent().pinned.map(eventId => {
promises.push(cli.getEventTimeline(this.props.room.getUnfilteredTimelineSet(), eventId, 0).then(timeline => { promises.push(cli.getEventTimeline(this.props.room.getUnfilteredTimelineSet(), eventId, 0).then(timeline => {
return {eventId, 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 => { 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) });
}); });
} }
}, },