PLT-2783 Reprint Last Message Entered Shortcut (#2966)
* added preliminary code * added comment code * semicolons are important * compatible with slash commands * too many semicolons
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
a4a06aa102
Коммит
1630892b4c
@@ -72,6 +72,7 @@ class CreateComment extends React.Component {
|
|||||||
const draft = PostStore.getCommentDraft(this.props.rootId);
|
const draft = PostStore.getCommentDraft(this.props.rootId);
|
||||||
this.state = {
|
this.state = {
|
||||||
messageText: draft.message,
|
messageText: draft.message,
|
||||||
|
lastMessage: '',
|
||||||
uploadsInProgress: draft.uploadsInProgress,
|
uploadsInProgress: draft.uploadsInProgress,
|
||||||
previews: draft.previews,
|
previews: draft.previews,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
@@ -172,6 +173,7 @@ class CreateComment extends React.Component {
|
|||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
messageText: '',
|
messageText: '',
|
||||||
|
lastMessage: this.state.messageText,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
postError: null,
|
postError: null,
|
||||||
previews: [],
|
previews: [],
|
||||||
@@ -203,7 +205,7 @@ class CreateComment extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
if (!e.ctrlKey && e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const lastPost = PostStore.getCurrentUsersLatestPost(this.props.channelId, this.props.rootId);
|
const lastPost = PostStore.getCurrentUsersLatestPost(this.props.channelId, this.props.rootId);
|
||||||
@@ -221,6 +223,18 @@ class CreateComment extends React.Component {
|
|||||||
comments: PostStore.getCommentCount(lastPost)
|
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() {
|
handleUploadClick() {
|
||||||
this.focusTextbox();
|
this.focusTextbox();
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class CreatePost extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
channelId: ChannelStore.getCurrentId(),
|
channelId: ChannelStore.getCurrentId(),
|
||||||
messageText: draft.messageText,
|
messageText: draft.messageText,
|
||||||
|
lastMessage: '',
|
||||||
uploadsInProgress: draft.uploadsInProgress,
|
uploadsInProgress: draft.uploadsInProgress,
|
||||||
previews: draft.previews,
|
previews: draft.previews,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
@@ -126,7 +127,7 @@ class CreatePost extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setState({submitting: true, serverError: null});
|
this.setState({submitting: true, serverError: null});
|
||||||
|
this.setState({lastMessage: this.state.messageText});
|
||||||
if (post.message.indexOf('/') === 0) {
|
if (post.message.indexOf('/') === 0) {
|
||||||
Client.executeCommand(
|
Client.executeCommand(
|
||||||
this.state.channelId,
|
this.state.channelId,
|
||||||
@@ -350,7 +351,7 @@ class CreatePost extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
if (!e.ctrlKey && e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const channelId = ChannelStore.getCurrentId();
|
const channelId = ChannelStore.getCurrentId();
|
||||||
@@ -371,6 +372,19 @@ class CreatePost extends React.Component {
|
|||||||
comments: PostStore.getCommentCount(lastPost)
|
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() {
|
showPostDeletedModal() {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user