Comment says "if we're currently in a 1:1..., start a new chat"
KentShikama opened this issue · 2 comments
KentShikama commented
Should I simply change this to "if we're NOT currently in a 1:1..., start a new chat"
or send in the following
diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js
index ddd0d1f..cc0351d 100644
--- a/src/components/views/rooms/MemberInfo.js
+++ b/src/components/views/rooms/MemberInfo.js
@@ -365,15 +365,9 @@ module.exports = React.createClass({
var currentRoom = MatrixClientPeg.get().getRoom(this.props.member.roomId);
currentMembers = currentRoom.getJoinedMembers();
}
- // if we're currently in a 1:1 with this user, start a new chat
- if (currentMembers && currentMembers.length === 2 &&
- userIds.indexOf(currentMembers[0].userId) !== -1 &&
- userIds.indexOf(currentMembers[1].userId) !== -1)
- {
+ if (no_existing_private_one_on_one()) {
existingRoomId = null;
- }
- // otherwise reuse the first private 1:1 we find
- else {
+ } else { // reuse existing private one on one
existingRoomId = null;
for (var i = 0; i < rooms.length; i++) {
@@ -391,6 +385,11 @@ module.exports = React.createClass({
}
}
}
+ function no_existing_private_one_on_one() {
+ return currentMembers && currentMembers.length === 2 &&
+ userIds.indexOf(currentMembers[0].userId) !== -1 &&
+ userIds.indexOf(currentMembers[1].userId) !== -1;
+ }
ara4n commented
oops, it was the comment that was wrong; fixed in bfe50c2. separately, the code is also broken, but we're working on that: element-hq/element-web#1613. thanks for calling it out!
ara4n commented
actually, the comment was correct (albeit confusing). If you are currently looking at a 1:1 chat with the user, the 'start chat' button should start a new chat.