Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #445 from matrix-org/dbkr/fix_hide_conference_rooms
Browse files Browse the repository at this point in the history
Fix: conference rooms were no longer hidden
  • Loading branch information
dbkr authored Sep 5, 2016
2 parents 8329651 + 04889a8 commit 80dd927
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
52 changes: 37 additions & 15 deletions src/MatrixTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,52 @@ 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;

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" ||
(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;
Expand Down
5 changes: 4 additions & 1 deletion src/components/views/rooms/RoomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 80dd927

Please sign in to comment.