From 7ecabe49d2130884cb71b03236344f0259787d17 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 17 Mar 2017 11:59:22 +0000 Subject: [PATCH] Fix people section DropTarget and refactor Rooms - Set the verb for the people section to "tag as direct chat". This requires some CSS modifications to Riot because it's a long bit of text relative to, say, "demote". - Because it's quite useful to be able to set the DM status of a room with just a boolean, add a convenience function for guessing a DM member and setting the DM flag on that room with the resulting member. --- src/Rooms.js | 18 ++++++++++++++++++ src/components/views/rooms/RoomList.js | 2 ++ 2 files changed, 20 insertions(+) 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({