diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js
index 43c5833faa..0c058a8859 100644
--- a/src/components/views/right_panel/UserInfo.js
+++ b/src/components/views/right_panel/UserInfo.js
@@ -186,6 +186,26 @@ const DirectChatsSection = withLegacyMatrixClient(({matrixClient: cli, userId, s
);
});
+function openDMForUser(cli, userId) {
+ const dmRooms = DMRoomMap.shared().getDMRoomsForUserId(userId);
+ const lastActiveRoom = dmRooms.reduce((lastActiveRoom, roomId) => {
+ const room = cli.getRoom(roomId);
+ if (!lastActiveRoom || (room && lastActiveRoom.getLastActiveTimestamp() < room.getLastActiveTimestamp())) {
+ return room;
+ }
+ return lastActiveRoom;
+ }, null);
+
+ if (lastActiveRoom) {
+ dis.dispatch({
+ action: 'view_room',
+ room_id: lastActiveRoom.roomId,
+ });
+ } else {
+ createRoom({dmUserId: userId});
+ }
+}
+
const UserOptionsSection = withLegacyMatrixClient(({matrixClient: cli, member, isIgnored, canInvite}) => {
let ignoreButton = null;
let insertPillButton = null;
@@ -286,10 +306,20 @@ const UserOptionsSection = withLegacyMatrixClient(({matrixClient: cli, member, i
);
+ let directMessageButton;
+ if (!isMe) {
+ directMessageButton = (
+