mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-03 01:38:51 +03:00
Initial pass at creating a direct message section
This commit is contained in:
parent
4f76398b29
commit
4aea2caefc
1 changed files with 38 additions and 27 deletions
|
@ -188,6 +188,7 @@ module.exports = React.createClass({
|
||||||
s.lists["im.vector.fake.invite"] = [];
|
s.lists["im.vector.fake.invite"] = [];
|
||||||
s.lists["m.favourite"] = [];
|
s.lists["m.favourite"] = [];
|
||||||
s.lists["im.vector.fake.recent"] = [];
|
s.lists["im.vector.fake.recent"] = [];
|
||||||
|
s.lists["im.vector.fake.direct"] = [];
|
||||||
s.lists["m.lowpriority"] = [];
|
s.lists["m.lowpriority"] = [];
|
||||||
s.lists["im.vector.fake.archived"] = [];
|
s.lists["im.vector.fake.archived"] = [];
|
||||||
|
|
||||||
|
@ -206,27 +207,28 @@ module.exports = React.createClass({
|
||||||
else if (me.membership == "join" || me.membership === "ban" ||
|
else 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()))
|
||||||
{
|
{
|
||||||
var shouldShowRoom = true;
|
// Used to split rooms via tags
|
||||||
|
var tagNames = Object.keys(room.tags);
|
||||||
// hiding conf rooms only ever toggles shouldShowRoom to false
|
// Used for 1:1 direct chats
|
||||||
if (HIDE_CONFERENCE_CHANS) {
|
|
||||||
// we want to hide the 1:1 conf<->user room and not the group chat
|
|
||||||
var joinedMembers = room.getJoinedMembers();
|
var joinedMembers = room.getJoinedMembers();
|
||||||
if (joinedMembers.length === 2) {
|
|
||||||
|
// 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) {
|
var otherMember = joinedMembers.filter(function(m) {
|
||||||
return m.userId !== me.userId
|
return m.userId !== me.userId
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
var ConfHandler = self.props.ConferenceHandler;
|
var ConfHandler = self.props.ConferenceHandler;
|
||||||
if (ConfHandler && ConfHandler.isConferenceUser(otherMember.userId)) {
|
if (ConfHandler && ConfHandler.isConferenceUser(otherMember.userId)) {
|
||||||
// console.log("Hiding conference 1:1 room %s", room.roomId);
|
// console.log("Hiding conference 1:1 room %s", room.roomId);
|
||||||
shouldShowRoom = false;
|
if (!HIDE_CONFERENCE_CHANS) {
|
||||||
|
s.lists["im.vector.fake.direct"].push(room);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
s.lists["im.vector.fake.direct"].push(room);
|
||||||
}
|
}
|
||||||
}
|
} else if (tagNames.length) {
|
||||||
|
|
||||||
if (shouldShowRoom) {
|
|
||||||
var tagNames = Object.keys(room.tags);
|
|
||||||
if (tagNames.length) {
|
|
||||||
for (var i = 0; i < tagNames.length; i++) {
|
for (var i = 0; i < tagNames.length; i++) {
|
||||||
var tagName = tagNames[i];
|
var tagName = tagNames[i];
|
||||||
s.lists[tagName] = s.lists[tagName] || [];
|
s.lists[tagName] = s.lists[tagName] || [];
|
||||||
|
@ -237,7 +239,6 @@ module.exports = React.createClass({
|
||||||
s.lists["im.vector.fake.recent"].push(room);
|
s.lists["im.vector.fake.recent"].push(room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (me.membership === "leave") {
|
else if (me.membership === "leave") {
|
||||||
s.lists["im.vector.fake.archived"].push(room);
|
s.lists["im.vector.fake.archived"].push(room);
|
||||||
}
|
}
|
||||||
|
@ -364,8 +365,18 @@ module.exports = React.createClass({
|
||||||
searchFilter={ self.props.searchFilter }
|
searchFilter={ self.props.searchFilter }
|
||||||
onShowMoreRooms={ self.onShowMoreRooms } />
|
onShowMoreRooms={ self.onShowMoreRooms } />
|
||||||
|
|
||||||
|
<RoomSubList list={ self.state.lists['im.vector.fake.direct'] }
|
||||||
|
label="Direct Messages"
|
||||||
|
editable={ false }
|
||||||
|
order="recent"
|
||||||
|
selectedRoom={ self.props.selectedRoom }
|
||||||
|
incomingCall={ self.state.incomingCall }
|
||||||
|
collapsed={ self.props.collapsed }
|
||||||
|
searchFilter={ self.props.searchFilter }
|
||||||
|
onShowMoreRooms={ self.onShowMoreRooms } />
|
||||||
|
|
||||||
{ Object.keys(self.state.lists).map(function(tagName) {
|
{ Object.keys(self.state.lists).map(function(tagName) {
|
||||||
if (!tagName.match(/^(m\.(favourite|lowpriority)|im\.vector\.fake\.(invite|recent|archived))$/)) {
|
if (!tagName.match(/^(m\.(favourite|lowpriority)|im\.vector\.fake\.(invite|recent|direct|archived))$/)) {
|
||||||
return <RoomSubList list={ self.state.lists[tagName] }
|
return <RoomSubList list={ self.state.lists[tagName] }
|
||||||
key={ tagName }
|
key={ tagName }
|
||||||
label={ tagName }
|
label={ tagName }
|
||||||
|
|
Loading…
Reference in a new issue