PLT-74: Enable Up Arrow keyboard shortcut to edit your last message
- fix bug where channel_id was not set if update_post ajax was "too fast" - fix bug js error if there is no last post, i.e. empty channel - renamed lastPostId to postId so it has a nicer api to be triggered from everywhere - fix a typo - automatically focus textarea on modal open
Этот коммит содержится в:
@@ -300,14 +300,17 @@ export default class CreatePost extends React.Component {
|
|||||||
|
|
||||||
const channelId = ChannelStore.getCurrentId();
|
const channelId = ChannelStore.getCurrentId();
|
||||||
const lastPost = PostStore.getCurrentUsersLatestPost(channelId);
|
const lastPost = PostStore.getCurrentUsersLatestPost(channelId);
|
||||||
|
if (!lastPost) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var type = (lastPost.root_id && lastPost.root_id.length > 0) ? 'Comment' : 'Post';
|
var type = (lastPost.root_id && lastPost.root_id.length > 0) ? 'Comment' : 'Post';
|
||||||
|
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.RECIEVED_EDIT_POST,
|
type: ActionTypes.RECIEVED_EDIT_POST,
|
||||||
refoucsId: '#post_textbox',
|
refocusId: '#post_textbox',
|
||||||
title: type,
|
title: type,
|
||||||
message: lastPost.message,
|
message: lastPost.message,
|
||||||
lastPostId: lastPost.id,
|
postId: lastPost.id,
|
||||||
channelId: lastPost.channel_id
|
channelId: lastPost.channel_id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,16 +37,15 @@ export default class EditPostModal extends React.Component {
|
|||||||
|
|
||||||
Client.updatePost(updatedPost,
|
Client.updatePost(updatedPost,
|
||||||
function success() {
|
function success() {
|
||||||
AsyncClient.getPosts(this.state.channel_id);
|
AsyncClient.getPosts(updatedPost.channel_id);
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}.bind(this),
|
},
|
||||||
function error(err) {
|
function error(err) {
|
||||||
AsyncClient.dispatchError(err, 'updatePost');
|
AsyncClient.dispatchError(err, 'updatePost');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$('#edit_post').modal('hide');
|
$('#edit_post').modal('hide');
|
||||||
$(this.state.refocusId).focus();
|
|
||||||
}
|
}
|
||||||
handleEditInput(editMessage) {
|
handleEditInput(editMessage) {
|
||||||
this.setState({editText: editMessage});
|
this.setState({editText: editMessage});
|
||||||
@@ -90,6 +89,15 @@ export default class EditPostModal extends React.Component {
|
|||||||
|
|
||||||
$(ReactDOM.findDOMNode(this.refs.modal)).on('shown.bs.modal', function onShown() {
|
$(ReactDOM.findDOMNode(this.refs.modal)).on('shown.bs.modal', function onShown() {
|
||||||
self.refs.editbox.resize();
|
self.refs.editbox.resize();
|
||||||
|
$('#edit_textbox').get(0).focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(React.findDOMNode(this.refs.modal)).on('hide.bs.modal', function onShown() {
|
||||||
|
if (self.state.refocusId !== '') {
|
||||||
|
setTimeout(() => {
|
||||||
|
$(self.state.refocusId).get(0).focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
PostStore.addEditPostListener(this.handleEditPostEvent);
|
PostStore.addEditPostListener(this.handleEditPostEvent);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user