From 50ef6957406d32db0d38b1b374ad070825493668 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Sep 2016 17:42:22 +0100 Subject: [PATCH 1/2] Fix: conference rooms were no longer hidden --- src/MatrixTools.js | 48 ++++++++++++++++++-------- src/components/views/rooms/RoomList.js | 5 ++- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/MatrixTools.js b/src/MatrixTools.js index 3bc7f28e20..f442904862 100644 --- a/src/MatrixTools.js +++ b/src/MatrixTools.js @@ -26,30 +26,48 @@ module.exports = { return room.getCanonicalAlias() || room.getAliases()[0]; }, - isDirectMessageRoom: function(room, me, ConferenceHandler, hideConferenceChans) { + /** + * If the room contains only two members including the logged-in user, + * return the other one. Otherwise, return null. + */ + getOnlyOtherMember(room, me) { + const joinedMembers = room.getJoinedMembers(); + + if (joinedMembers.length === 2) { + return joinedMembers.filter(function(m) { + return m.userId !== me.userId + })[0]; + } + + return null; + }, + + isConfCallRoom: function(room, me, conferenceHandler) { + if (!conferenceHandler) return false; + + const otherMember = this.getOnlyOtherMember(room, me); + if (otherMember === null) { + return false; + } + + if (conferenceHandler.isConferenceUser(otherMember.userId)) { + return true; + } + }, + + isDirectMessageRoom: function(room, me) { if (me.membership == "join" || me.membership === "ban" || (me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) { // Used to split rooms via tags - var tagNames = Object.keys(room.tags); + const tagNames = Object.keys(room.tags); // Used for 1:1 direct chats - var joinedMembers = room.getJoinedMembers(); + const joinedMembers = room.getJoinedMembers(); // 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) { - var otherMember = joinedMembers.filter(function(m) { - return m.userId !== me.userId - })[0]; - - if (ConferenceHandler && ConferenceHandler.isConferenceUser(otherMember.userId)) { - // console.log("Hiding conference 1:1 room %s", room.roomId); - if (!hideConferenceChans) { - return true; - } - } else { - return true; - } + return true; } } return false; diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 206bf8504e..4fef4ff0a4 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -221,7 +221,10 @@ module.exports = React.createClass({ if (me.membership == "invite") { s.lists["im.vector.fake.invite"].push(room); } - else if (MatrixTools.isDirectMessageRoom(room, me, self.props.ConferenceHandler, HIDE_CONFERENCE_CHANS)) { + else if (HIDE_CONFERENCE_CHANS && MatrixTools.isConfCallRoom(room, me, self.props.ConferenceHandler)) { + // skip past this room & don't put it in any lists + } + else if (MatrixTools.isDirectMessageRoom(room, me)) { // "Direct Message" rooms s.lists["im.vector.fake.direct"].push(room); } From 04889a89ecd732e84ad541348bf60b241636bdd1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Sep 2016 18:35:32 +0100 Subject: [PATCH 2/2] Only count rooms we're in as DM rooms --- src/MatrixTools.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MatrixTools.js b/src/MatrixTools.js index f442904862..b95e21a4af 100644 --- a/src/MatrixTools.js +++ b/src/MatrixTools.js @@ -45,6 +45,10 @@ module.exports = { isConfCallRoom: function(room, me, conferenceHandler) { if (!conferenceHandler) return false; + if (me.membership != "join") { + return false; + } + const otherMember = this.getOnlyOtherMember(room, me); if (otherMember === null) { return false;