From b66c449bd7ea93738b346092f19fd4fc38c5159a Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 20 Sep 2016 16:08:11 +0100 Subject: [PATCH 1/3] Comment typo and out comment in more sensible place --- src/components/structures/RoomView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 91d1918c0f..e4ef1433f1 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -679,9 +679,9 @@ module.exports = React.createClass({ if (this.state.room) { const me = this.state.room.getMember(MatrixClientPeg.get().credentials.userId); if (me && me.membership == 'invite') { - // The 'direct' hihnt is there, so declare that this is a DM room for - // whoever invited us. if (me.events.member.getContent().is_direct) { + // The 'direct' hint is there, so declare that this is a DM room for + // whoever invited us. return Rooms.setDMRoom(this.state.room.roomId, me.events.member.getSender()); } } From d1a5e54a69cf8036875bc391addcff8af5fd3bdb Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 20 Sep 2016 17:59:46 +0100 Subject: [PATCH 2/3] 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. --- src/Rooms.js | 2 +- src/components/structures/RoomView.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Rooms.js b/src/Rooms.js index b70aad90a7..ff805b9ef1 100644 --- a/src/Rooms.js +++ b/src/Rooms.js @@ -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 diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index e4ef1433f1..ae1b0febe8 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -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 }); From 5b216df28eda418a843d74a34f77076ffa966b76 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Sep 2016 09:57:17 +0100 Subject: [PATCH 3/3] Not joined members any more --- src/Rooms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rooms.js b/src/Rooms.js index ff805b9ef1..cf62f2dda0 100644 --- a/src/Rooms.js +++ b/src/Rooms.js @@ -68,11 +68,11 @@ 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.currentState.getMembers(); + const members = 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 - if (joinedMembers.length === 2 && !tagNames.length) { + if (members.length === 2 && !tagNames.length) { return true; } }