mirror of https://github.com/vector-im/riot-web
Merge pull request #1620 from matrix-org/rav/fix_memberpresence_avatar
MemberPresenceAvatar: fix null referencespull/21833/head
commit
b2e80a8ee2
|
@ -25,6 +25,7 @@ import dispatcher from "../../../dispatcher";
|
||||||
import * as ContextualMenu from "../../structures/ContextualMenu";
|
import * as ContextualMenu from "../../structures/ContextualMenu";
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
|
|
||||||
|
// This is an avatar with presence information and controls on it.
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MemberPresenceAvatar',
|
displayName: 'MemberPresenceAvatar',
|
||||||
|
|
||||||
|
@ -44,8 +45,15 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
const presenceState = this.props.member.user.presence;
|
let presenceState = null;
|
||||||
const presenceMessage = this.props.member.user.presenceStatusMsg;
|
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 {
|
return {
|
||||||
status: presenceState,
|
status: presenceState,
|
||||||
message: presenceMessage,
|
message: presenceMessage,
|
||||||
|
@ -109,6 +117,8 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// XXX NB the following assumes that user is non-null, which is not valid
|
||||||
// const presenceState = this.props.member.user.presence;
|
// const presenceState = this.props.member.user.presence;
|
||||||
// const presenceLastActiveAgo = this.props.member.user.lastActiveAgo;
|
// const presenceLastActiveAgo = this.props.member.user.lastActiveAgo;
|
||||||
// const presenceLastTs = this.props.member.user.lastPresenceTs;
|
// const presenceLastTs = this.props.member.user.lastPresenceTs;
|
||||||
|
@ -133,7 +143,8 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
|
|
||||||
// LABS: Disable presence management functions for now
|
// LABS: Disable presence management functions for now
|
||||||
if (!SettingsStore.isFeatureEnabled("feature_presence_management")) {
|
// Also disable the presence information if there's no status information
|
||||||
|
if (!SettingsStore.isFeatureEnabled("feature_presence_management") || !this.state.status) {
|
||||||
statusNode = null;
|
statusNode = null;
|
||||||
onClickFn = null;
|
onClickFn = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue