Merge pull request #445 from matrix-org/dbkr/fix_hide_conference_rooms

Fix: conference rooms were no longer hidden
This commit is contained in:
David Baker 2016-09-05 18:39:15 +01:00 committed by GitHub
commit 80dd927275
2 changed files with 41 additions and 16 deletions

View file

@ -26,31 +26,53 @@ module.exports = {
return room.getCanonicalAlias() || room.getAliases()[0]; 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;
if (me.membership != "join") {
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" || if (me.membership == "join" || me.membership === "ban" ||
(me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) (me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey()))
{ {
// Used to split rooms via tags // Used to split rooms via tags
var tagNames = Object.keys(room.tags); const tagNames = Object.keys(room.tags);
// Used for 1:1 direct chats // 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 // Show 1:1 chats in seperate "Direct Messages" section as long as they haven't
// been moved to a different tag section // been moved to a different tag section
if (joinedMembers.length === 2 && !tagNames.length) { 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; return true;
} }
} else {
return true;
}
}
} }
return false; return false;
}, },

View file

@ -221,7 +221,10 @@ module.exports = React.createClass({
if (me.membership == "invite") { if (me.membership == "invite") {
s.lists["im.vector.fake.invite"].push(room); 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 // "Direct Message" rooms
s.lists["im.vector.fake.direct"].push(room); s.lists["im.vector.fake.direct"].push(room);
} }