diff options
author | =Corey Hulen <corey@hulen.com> | 2015-10-22 09:19:18 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-10-22 09:19:18 -0700 |
commit | 54894e90ac705eab3bf0f34c8dd197bb0929feae (patch) | |
tree | 2fd5c6bc1bdb8cef1ea6095e8f12f8fd73a52ce9 /web/react/components/create_comment.jsx | |
parent | c4c04e5f02253dfdfc2bd09e06955f1f5932ce18 (diff) | |
parent | 649f42e3fc706f8fa829276bcdb825381bc703f2 (diff) | |
download | chat-54894e90ac705eab3bf0f34c8dd197bb0929feae.tar.gz chat-54894e90ac705eab3bf0f34c8dd197bb0929feae.tar.bz2 chat-54894e90ac705eab3bf0f34c8dd197bb0929feae.zip |
Fixing merge conflict
Diffstat (limited to 'web/react/components/create_comment.jsx')
-rw-r--r-- | web/react/components/create_comment.jsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 12d1af6ff..435c7d542 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -13,8 +13,10 @@ const MsgTyping = require('./msg_typing.jsx'); const FileUpload = require('./file_upload.jsx'); const FilePreview = require('./file_preview.jsx'); const Utils = require('../utils/utils.jsx'); + const Constants = require('../utils/constants.jsx'); const ActionTypes = Constants.ActionTypes; +const KeyCodes = Constants.KeyCodes; export default class CreateComment extends React.Component { constructor(props) { @@ -25,6 +27,7 @@ export default class CreateComment extends React.Component { this.handleSubmit = this.handleSubmit.bind(this); this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this); this.handleUserInput = this.handleUserInput.bind(this); + this.handleArrowUp = this.handleArrowUp.bind(this); this.handleUploadStart = this.handleUploadStart.bind(this); this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this); this.handleUploadError = this.handleUploadError.bind(this); @@ -158,6 +161,26 @@ export default class CreateComment extends React.Component { $('.post-right__scroll').perfectScrollbar('update'); this.setState({messageText: messageText}); } + handleArrowUp(e) { + if (e.keyCode === KeyCodes.UP && this.state.messageText === '') { + e.preventDefault(); + + const channelId = ChannelStore.getCurrentId(); + const lastPost = PostStore.getCurrentUsersLatestPost(channelId, this.props.rootId); + if (!lastPost) { + return; + } + + AppDispatcher.handleViewAction({ + type: ActionTypes.RECIEVED_EDIT_POST, + refocusId: '#reply_textbox', + title: 'Comment', + message: lastPost.message, + postId: lastPost.id, + channelId: lastPost.channel_id + }); + } + } handleUploadStart(clientIds) { let draft = PostStore.getCommentDraft(this.props.rootId); @@ -290,6 +313,7 @@ export default class CreateComment extends React.Component { <Textbox onUserInput={this.handleUserInput} onKeyPress={this.commentMsgKeyPress} + onKeyDown={this.handleArrowUp} messageText={this.state.messageText} createMessage='Add a comment...' initialText='' |