summaryrefslogtreecommitdiffstats
path: root/webapp/components/create_comment.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components/create_comment.jsx')
-rw-r--r--webapp/components/create_comment.jsx37
1 files changed, 26 insertions, 11 deletions
diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx
index 30e89e500..616257f37 100644
--- a/webapp/components/create_comment.jsx
+++ b/webapp/components/create_comment.jsx
@@ -16,7 +16,7 @@ import MsgTyping from './msg_typing.jsx';
import FileUpload from './file_upload.jsx';
import FilePreview from './file_preview.jsx';
import * as Utils from 'utils/utils.jsx';
-import * as GlobalActions from 'action_creators/global_actions.jsx';
+import * as GlobalActions from 'actions/global_actions.jsx';
import Constants from 'utils/constants.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,
@@ -111,7 +112,7 @@ class CreateComment extends React.Component {
return;
}
- let post = {};
+ const post = {};
post.filenames = [];
post.message = this.state.messageText;
@@ -144,7 +145,7 @@ class CreateComment extends React.Component {
AsyncClient.getPosts(this.props.channelId);
const channel = ChannelStore.get(this.props.channelId);
- let member = ChannelStore.getMember(this.props.channelId);
+ const member = ChannelStore.getMember(this.props.channelId);
member.msg_count = channel.total_msg_count;
member.last_viewed_at = Date.now();
ChannelStore.setChannelMember(member);
@@ -172,6 +173,7 @@ class CreateComment extends React.Component {
this.setState({
messageText: '',
+ lastMessage: this.state.messageText,
submitting: false,
postError: null,
previews: [],
@@ -190,7 +192,7 @@ class CreateComment extends React.Component {
GlobalActions.emitLocalUserTypingEvent(this.props.channelId, this.props.rootId);
}
handleUserInput(messageText) {
- let draft = PostStore.getCommentDraft(this.props.rootId);
+ const draft = PostStore.getCommentDraft(this.props.rootId);
draft.message = messageText;
PostStore.storeCommentDraft(this.props.rootId, draft);
@@ -203,7 +205,7 @@ class CreateComment extends React.Component {
return;
}
- if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
+ if (!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && e.keyCode === KeyCodes.UP && this.state.messageText === '') {
e.preventDefault();
const lastPost = PostStore.getCurrentUsersLatestPost(this.props.channelId, this.props.rootId);
@@ -221,12 +223,25 @@ class CreateComment extends React.Component {
comments: PostStore.getCommentCount(lastPost)
});
}
+
+ if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.keyCode === KeyCodes.UP) {
+ e.preventDefault();
+ 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();
}
handleUploadStart(clientIds) {
- let draft = PostStore.getCommentDraft(this.props.rootId);
+ const draft = PostStore.getCommentDraft(this.props.rootId);
draft.uploadsInProgress = draft.uploadsInProgress.concat(clientIds);
PostStore.storeCommentDraft(this.props.rootId, draft);
@@ -238,7 +253,7 @@ class CreateComment extends React.Component {
this.focusTextbox();
}
handleFileUploadComplete(filenames, clientIds) {
- let draft = PostStore.getCommentDraft(this.props.rootId);
+ const draft = PostStore.getCommentDraft(this.props.rootId);
// remove each finished file from uploads
for (let i = 0; i < clientIds.length; i++) {
@@ -258,7 +273,7 @@ class CreateComment extends React.Component {
if (clientId === -1) {
this.setState({serverError: err});
} else {
- let draft = PostStore.getCommentDraft(this.props.rootId);
+ const draft = PostStore.getCommentDraft(this.props.rootId);
const index = draft.uploadsInProgress.indexOf(clientId);
if (index !== -1) {
@@ -271,8 +286,8 @@ class CreateComment extends React.Component {
}
}
removePreview(id) {
- let previews = this.state.previews;
- let uploadsInProgress = this.state.uploadsInProgress;
+ const previews = this.state.previews;
+ const uploadsInProgress = this.state.uploadsInProgress;
// id can either be the path of an uploaded file or the client id of an in progress upload
let index = previews.indexOf(id);
@@ -287,7 +302,7 @@ class CreateComment extends React.Component {
previews.splice(index, 1);
}
- let draft = PostStore.getCommentDraft(this.props.rootId);
+ const draft = PostStore.getCommentDraft(this.props.rootId);
draft.previews = previews;
draft.uploadsInProgress = uploadsInProgress;
PostStore.storeCommentDraft(this.props.rootId, draft);