mirror of https://github.com/vector-im/riot-web
Check if a room looks like a DM rooms on joining
and mark it as one if so. Also change the heuristic to only count rooms with 2 total members rather than 2 joined members, otherwise this is going to mark any room as a DM if someone creates a room, invites a bunch of people and you happen to be first to join.pull/21833/head
parent
b66c449bd7
commit
d1a5e54a69
|
@ -68,7 +68,7 @@ export function looksLikeDirectMessageRoom(room, me) {
|
|||
// Used to split rooms via tags
|
||||
const tagNames = Object.keys(room.tags);
|
||||
// Used for 1:1 direct chats
|
||||
const joinedMembers = room.getJoinedMembers();
|
||||
const joinedMembers = room.currentState.getMembers();
|
||||
|
||||
// Show 1:1 chats in seperate "Direct Messages" section as long as they haven't
|
||||
// been moved to a different tag section
|
||||
|
|
|
@ -451,6 +451,7 @@ module.exports = React.createClass({
|
|||
room: room,
|
||||
joining: false,
|
||||
});
|
||||
|
||||
this._onRoomLoaded(room);
|
||||
}
|
||||
},
|
||||
|
@ -520,6 +521,17 @@ module.exports = React.createClass({
|
|||
// into.
|
||||
var me = MatrixClientPeg.get().credentials.userId;
|
||||
if (this.state.joining && this.state.room.hasMembershipState(me, "join")) {
|
||||
// Having just joined a room, check to see if it looks like a DM room, and if so,
|
||||
// mark it as one. This is to work around the fact that some clients don't support
|
||||
// is_direct. We should remove this once they do.
|
||||
const me = this.state.room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||
if (Rooms.looksLikeDirectMessageRoom(this.state.room, me)) {
|
||||
// XXX: There's not a whole lot we can really do if this fails: at best
|
||||
// perhaps we could try a couple more times, but since it's a temporary
|
||||
// compatability workaround, let's not bother.
|
||||
Rooms.setDMRoom(this.state.room.roomId, me.events.member.getSender()).done();
|
||||
}
|
||||
|
||||
this.setState({
|
||||
joining: false
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue