diff options
author | David Lu <david.lu@hotmail.com> | 2016-05-12 07:48:29 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-05-12 07:48:29 -0400 |
commit | 1630892b4cb03ad2fb4fc5258a784a6adcf50779 (patch) | |
tree | df5ea6df18871b6e116ecfd416f62fef2fbf2f9a /webapp/components/create_comment.jsx | |
parent | a4a06aa102e4abc1c4e75098f723d7b64dffeee5 (diff) | |
download | chat-1630892b4cb03ad2fb4fc5258a784a6adcf50779.tar.gz chat-1630892b4cb03ad2fb4fc5258a784a6adcf50779.tar.bz2 chat-1630892b4cb03ad2fb4fc5258a784a6adcf50779.zip |
PLT-2783 Reprint Last Message Entered Shortcut (#2966)
* added preliminary code
* added comment code
* semicolons are important
* compatible with slash commands
* too many semicolons
Diffstat (limited to 'webapp/components/create_comment.jsx')
-rw-r--r-- | webapp/components/create_comment.jsx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx index 30e89e500..42e5dd336 100644 --- a/webapp/components/create_comment.jsx +++ b/webapp/components/create_comment.jsx @@ -72,6 +72,7 @@ class CreateComment extends React.Component { const draft = PostStore.getCommentDraft(this.props.rootId); this.state = { messageText: draft.message, + lastMessage: '', uploadsInProgress: draft.uploadsInProgress, previews: draft.previews, submitting: false, @@ -172,6 +173,7 @@ class CreateComment extends React.Component { this.setState({ messageText: '', + lastMessage: this.state.messageText, submitting: false, postError: null, previews: [], @@ -203,7 +205,7 @@ class CreateComment extends React.Component { return; } - if (e.keyCode === KeyCodes.UP && this.state.messageText === '') { + if (!e.ctrlKey && e.keyCode === KeyCodes.UP && this.state.messageText === '') { e.preventDefault(); const lastPost = PostStore.getCurrentUsersLatestPost(this.props.channelId, this.props.rootId); @@ -221,6 +223,18 @@ class CreateComment extends React.Component { comments: PostStore.getCommentCount(lastPost) }); } + + if (e.ctrlKey && e.keyCode === KeyCodes.UP) { + const lastPost = PostStore.getCurrentUsersLatestPost(this.props.channelId, this.props.rootId); + if (!lastPost) { + return; + } + let message = lastPost.message; + if (this.state.lastMessage !== '') { + message = this.state.lastMessage; + } + this.setState({messageText: message}); + } } handleUploadClick() { this.focusTextbox(); |