diff --git a/src/Rooms.js b/src/Rooms.js index fbcc843ad2..0f81bf5391 100644 --- a/src/Rooms.js +++ b/src/Rooms.js @@ -79,6 +79,24 @@ export function looksLikeDirectMessageRoom(room, me) { return false; } +export function guessAndSetDMRoom(room, isDirect) { + let newTarget; + if (isDirect) { + const guessedTarget = guessDMRoomTarget( + room, room.getMember(MatrixClientPeg.get().credentials.userId), + ); + newTarget = guessedTarget.userId; + } else { + newTarget = null; + } + + // give some time for the user to see the icon change first, since + // this will hide the context menu once it completes + return q.delay(500).then(() => { + return setDMRoom(room.roomId, newTarget); + }); +} + /** * Marks or unmarks the given room as being as a DM room. * @param {string} roomId The ID of the room to modify diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index e84c56e693..51811f672a 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -485,6 +485,8 @@ module.exports = React.createClass({