Allow user to choose from existing DMs on new chat#736
Conversation
When creating a new chat with one person, show a dialog that asks the user whether they'd like to use an existing chat or actually create a new room. Fixes element-hq/element-web#2760
| unread={Unread.doesRoomHaveUnreadMessages(room)} | ||
| highlight={highlight} | ||
| isInvite={me.membership == "invite"} | ||
| onClick={() => this.props.onFinished(true)} |
There was a problem hiding this comment.
This is generally considered bad since a new arrow function will be created on each render, resulting in the props not being equal, which causes a DOM update on every render (it's equivalent to binding in render (https://ryanfunduk.com/articles/never-bind-in-render/).
In this case it's easy to work around since you can just have a member function that calls onFinished(true)
|
|
||
| export default class CreateOrReuseChatDialog extends React.Component { | ||
|
|
||
| constructor (props) { |
There was a problem hiding this comment.
Style nitpick: no need for space between method name & opening bracket.
| }); | ||
| if (this.props.onClick) { | ||
| this.props.onClick(); | ||
| } |
There was a problem hiding this comment.
Presumably this is no longer necessary?
| _onAction(payload) { | ||
| switch(payload.action) { | ||
| case 'view_room': | ||
| this.props.onFinished(true); |
There was a problem hiding this comment.
Similar to the discussion in #riot-dev, I don't particularly like using view-room dispatches for this: I know there's a modal dialog being displayed at the time, but seems entirely possible that something else will decide to view a different room while the modal is being displayed, at which point the modal goes away. In essence, the thing that causes the modal to go away should be the user interaction with the dialog finishing, not the currently viewed room changing.
There was a problem hiding this comment.
seems entirely possible that something else will decide to view a different room while the modal is being displayed
This is true. I would feel better about using a callback if that was the only thing that RoomTile was responsible for. i.e. move view_room dispatch out of RoomTile and into the onClick that gets passed into it.
There was a problem hiding this comment.
Yeah, I was going to say it's not great that something ekse also happens in addition to the onClick, but didn't really want to make you change all the other places RoomTile is used. Up to you. :)
There was a problem hiding this comment.
Refactoring FTW!
But make sure that nothing other than the callback is done when RoomTile is clicked.
|
Requires element-hq/element-web#3376, which should be merged first. |
Support for e2e key backups
When creating a new chat with one person, show a dialog that asks the user whether they'd like to use an existing chat or actually create a new room.
Fixes element-hq/element-web#2760