Only Direct Message rooms, that aren't parted or forgotten are used
This commit is contained in:
parent
d0523cae70
commit
d1974a75fd
1 changed files with 18 additions and 4 deletions
|
@ -81,7 +81,6 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onStartChat: function() {
|
onStartChat: function() {
|
||||||
const dmRoomMap = new DMRoomMap(MatrixClientPeg.get());
|
|
||||||
var addr;
|
var addr;
|
||||||
|
|
||||||
// Either an address tile was created, or text input is being used
|
// Either an address tile was created, or text input is being used
|
||||||
|
@ -93,13 +92,13 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// Check if the addr is a valid type
|
// Check if the addr is a valid type
|
||||||
if (Invite.getAddressType(addr) === "mx") {
|
if (Invite.getAddressType(addr) === "mx") {
|
||||||
var dmRooms = dmRoomMap.getDMRoomsForUserId(addr);
|
var room = this._getDirectMessageRoom(addr);
|
||||||
if (dmRooms) {
|
if (room) {
|
||||||
// A Direct Message room already exists for this user and you
|
// A Direct Message room already exists for this user and you
|
||||||
// so go straight to that room
|
// so go straight to that room
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: 'view_room',
|
||||||
room_id: dmRooms[0],
|
room_id: room.roomId,
|
||||||
});
|
});
|
||||||
this.props.onFinished(true, addr);
|
this.props.onFinished(true, addr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,6 +240,21 @@ module.exports = React.createClass({
|
||||||
return queryList;
|
return queryList;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getDirectMessageRoom: function(addr) {
|
||||||
|
const dmRoomMap = new DMRoomMap(MatrixClientPeg.get());
|
||||||
|
var dmRooms = dmRoomMap.getDMRoomsForUserId(addr);
|
||||||
|
if (dmRooms.length > 0) {
|
||||||
|
// Cycle through all the DM rooms and find the first non forgotten or parted room
|
||||||
|
for (let i = 0; i < dmRooms.length; i++) {
|
||||||
|
let room = MatrixClientPeg.get().getRoom(dmRooms[i]);
|
||||||
|
if (room) {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
_startChat: function(addr) {
|
_startChat: function(addr) {
|
||||||
// Start the chat
|
// Start the chat
|
||||||
createRoom().then(function(roomId) {
|
createRoom().then(function(roomId) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue