diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 85cc85be49..d45813cb17 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -297,10 +297,9 @@ module.exports = React.createClass({ onEmoteSenderClick: function(event) { const mxEvent = this.props.mxEvent; - const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender(); dis.dispatch({ action: 'insert_displayname', - displayname: name.replace(' (IRC)', ''), + user_id: mxEvent.getSender(), }); }, diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 68ef3a1f44..32f0739795 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -357,10 +357,10 @@ module.exports = withMatrixClient(React.createClass({ }, onSenderProfileClick: function(event) { - var mxEvent = this.props.mxEvent; + const mxEvent = this.props.mxEvent; dis.dispatch({ action: 'insert_displayname', - displayname: (mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender()).replace(' (IRC)', ''), + user_id: mxEvent.getSender(), }); }, diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index d5a486bb39..29f627180b 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -275,15 +275,23 @@ export default class MessageComposerInput extends React.Component { case 'focus_composer': editor.focus(); break; - - // TODO change this so we insert a complete user alias - case 'insert_displayname': { + const entityKey = Entity.create( + 'LINK', 'IMMUTABLE', + { url: `https://matrix.to/#/${payload.user_id}`}, + ); + const selection = this.state.editorState.getSelection(); contentState = Modifier.replaceText( contentState, - this.state.editorState.getSelection(), - `${payload.displayname}: `, + selection, + `${payload.user_id}`, + null, + entityKey, ); + + const suffix = selection.getStartOffset() === 0 ? ': ' : ' '; + contentState = Modifier.replaceText(contentState, contentState.getSelectionAfter(), suffix); + let editorState = EditorState.push(this.state.editorState, contentState, 'insert-characters'); editorState = EditorState.forceSelection(editorState, contentState.getSelectionAfter()); this.onEditorContentChanged(editorState);