Don't assume RoomMember has a state event in direct chat detection
Instead call the method on the member that takes lazy loading into account
This commit is contained in:
parent
de3e143a8f
commit
19387805ac
1 changed files with 7 additions and 16 deletions
|
@ -749,21 +749,15 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateDMState() {
|
_updateDMState() {
|
||||||
const me = this.state.room.getMember(MatrixClientPeg.get().credentials.userId);
|
const me = this.state.room.getMember(MatrixClientPeg.get().getUserId());
|
||||||
if (!me || me.membership !== "join") {
|
if (!me || me.membership !== "join") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const roomId = this.state.room.roomId;
|
||||||
|
const dmInviter = me.getDirectChatInviter();
|
||||||
|
|
||||||
// The user may have accepted an invite with is_direct set
|
if (dmInviter) {
|
||||||
if (me.events.member.getPrevContent().membership === "invite" &&
|
Rooms.setDMRoom(roomId, dmInviter);
|
||||||
me.events.member.getPrevContent().is_direct
|
|
||||||
) {
|
|
||||||
// This is a DM with the sender of the invite event (which we assume
|
|
||||||
// preceded the join event)
|
|
||||||
Rooms.setDMRoom(
|
|
||||||
this.state.room.roomId,
|
|
||||||
me.events.member.getUnsigned().prev_sender,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,11 +771,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// The user may have sent an invite with is_direct sent
|
// The user may have sent an invite with is_direct sent
|
||||||
const other = invitedMembers[0];
|
const other = invitedMembers[0];
|
||||||
if (other &&
|
if (other && !!other.getDirectChatInviter()) {
|
||||||
other.membership === "invite" &&
|
Rooms.setDMRoom(roomId, other.userId);
|
||||||
other.events.member.getContent().is_direct
|
|
||||||
) {
|
|
||||||
Rooms.setDMRoom(this.state.room.roomId, other.userId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue