mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
MemberPresenceAvatar: fix null references
avoid assuming that `member` has a `user`
This commit is contained in:
parent
02629d13d9
commit
4e7fd55fb4
1 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue