mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
If a Direct Message room already exists for the users specified, then just go to that room, rather than creating another one
This commit is contained in:
parent
7dfb8857d8
commit
d0523cae70
1 changed files with 19 additions and 2 deletions
|
@ -20,7 +20,9 @@ var sdk = require("../../../index");
|
|||
var Invite = require("../../../Invite");
|
||||
var createRoom = require("../../../createRoom");
|
||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||
var DMRoomMap = require('../../../utils/DMRoomMap');
|
||||
var rate_limited_func = require("../../../ratelimitedfunc");
|
||||
var dis = require("../../../dispatcher");
|
||||
var Modal = require('../../../Modal');
|
||||
|
||||
const TRUNCATE_QUERY_LIST = 40;
|
||||
|
@ -79,7 +81,9 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
onStartChat: function() {
|
||||
const dmRoomMap = new DMRoomMap(MatrixClientPeg.get());
|
||||
var addr;
|
||||
|
||||
// Either an address tile was created, or text input is being used
|
||||
if (this.state.user) {
|
||||
addr = this.state.user.userId;
|
||||
|
@ -88,7 +92,20 @@ module.exports = React.createClass({
|
|||
}
|
||||
|
||||
// Check if the addr is a valid type
|
||||
if (Invite.getAddressType(addr) !== null) {
|
||||
if (Invite.getAddressType(addr) === "mx") {
|
||||
var dmRooms = dmRoomMap.getDMRoomsForUserId(addr);
|
||||
if (dmRooms) {
|
||||
// A Direct Message room already exists for this user and you
|
||||
// so go straight to that room
|
||||
dis.dispatch({
|
||||
action: 'view_room',
|
||||
room_id: dmRooms[0],
|
||||
});
|
||||
this.props.onFinished(true, addr);
|
||||
} else {
|
||||
this._startChat(addr);
|
||||
}
|
||||
} else if (Invite.getAddressType(addr) === "email") {
|
||||
this._startChat(addr);
|
||||
} else {
|
||||
// Nothing to do, so focus back on the textinput
|
||||
|
@ -211,7 +228,7 @@ module.exports = React.createClass({
|
|||
"mx_ChatInviteDialog_selected": this.state.selected === i,
|
||||
});
|
||||
|
||||
// NOTE: Defaulting to "vector" as the network, until the network backend stuff is done
|
||||
// NOTE: Defaulting to "vector" as the network, until the network backend stuff is done.
|
||||
// Saving the queryListElement so we can use it to work out, in the componentDidUpdate
|
||||
// method, how far to scroll when using the arrow keys
|
||||
queryList.push(
|
||||
|
|
Loading…
Reference in a new issue