summaryrefslogtreecommitdiffstats
path: root/webapp/components/create_post.jsx
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-05-12 07:48:29 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-12 07:48:29 -0400
commit1630892b4cb03ad2fb4fc5258a784a6adcf50779 (patch)
treedf5ea6df18871b6e116ecfd416f62fef2fbf2f9a /webapp/components/create_post.jsx
parenta4a06aa102e4abc1c4e75098f723d7b64dffeee5 (diff)
downloadchat-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_post.jsx')
-rw-r--r--webapp/components/create_post.jsx18
1 files changed, 16 insertions, 2 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index d173fe42b..863f969df 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -77,6 +77,7 @@ class CreatePost extends React.Component {
this.state = {
channelId: ChannelStore.getCurrentId(),
messageText: draft.messageText,
+ lastMessage: '',
uploadsInProgress: draft.uploadsInProgress,
previews: draft.previews,
submitting: false,
@@ -126,7 +127,7 @@ class CreatePost extends React.Component {
}
this.setState({submitting: true, serverError: null});
-
+ this.setState({lastMessage: this.state.messageText});
if (post.message.indexOf('/') === 0) {
Client.executeCommand(
this.state.channelId,
@@ -350,7 +351,7 @@ class CreatePost 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 channelId = ChannelStore.getCurrentId();
@@ -371,6 +372,19 @@ class CreatePost extends React.Component {
comments: PostStore.getCommentCount(lastPost)
});
}
+
+ if (e.ctrlKey && e.keyCode === KeyCodes.UP) {
+ const channelId = ChannelStore.getCurrentId();
+ const lastPost = PostStore.getCurrentUsersLatestPost(channelId);
+ if (!lastPost) {
+ return;
+ }
+ let message = lastPost.message;
+ if (this.state.lastMessage !== '') {
+ message = this.state.lastMessage;
+ }
+ this.setState({messageText: message});
+ }
}
showPostDeletedModal() {
this.setState({