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.
This commit is contained in:
Luke Barnard 2017-03-17 11:59:22 +00:00
parent f8a1634720
commit 7ecabe49d2
2 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -485,6 +485,8 @@ module.exports = React.createClass({
<RoomSubList list={ self.state.lists['im.vector.fake.direct'] }
label="People"
tagName="im.vector.fake.direct"
verb="tag direct chat"
editable={ true }
order="recent"
selectedRoom={ self.props.selectedRoom }