From 4e7fd55fb459e2e6fd539b6bcf6527eec7e2db9f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 17 Nov 2017 14:35:33 +0000 Subject: [PATCH] MemberPresenceAvatar: fix null references avoid assuming that `member` has a `user` --- .../views/avatars/MemberPresenceAvatar.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/views/avatars/MemberPresenceAvatar.js b/src/components/views/avatars/MemberPresenceAvatar.js index 648b798b67..091ed15e75 100644 --- a/src/components/views/avatars/MemberPresenceAvatar.js +++ b/src/components/views/avatars/MemberPresenceAvatar.js @@ -44,8 +44,15 @@ module.exports = React.createClass({ }, getInitialState: function() { - const presenceState = this.props.member.user.presence; - const presenceMessage = this.props.member.user.presenceStatusMsg; + let presenceState = null; + let presenceMessage = null; + + // RoomMembers do not necessarily have a user. + if (this.props.member.user) { + presenceState = this.props.member.user.presence; + presenceMessage = this.props.member.user.presenceStatusMsg; + } + return { status: presenceState, message: presenceMessage, @@ -109,6 +116,8 @@ module.exports = React.createClass({ }); e.stopPropagation(); + + // XXX NB the following assumes that user is non-null, which is not valid // const presenceState = this.props.member.user.presence; // const presenceLastActiveAgo = this.props.member.user.lastActiveAgo; // const presenceLastTs = this.props.member.user.lastPresenceTs;