Mm 52178 Fix "registerMessageWillBeUpdatedHook" not running (#23763)
Automatic Merge
Этот коммит содержится в:
@@ -29,6 +29,7 @@ import {ModalData} from 'types/actions';
|
||||
import {PostDraft} from '../../types/store/draft';
|
||||
|
||||
import EditPostFooter from './edit_post_footer';
|
||||
import {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
type DialogProps = {
|
||||
post?: Post;
|
||||
@@ -42,6 +43,7 @@ export type Actions = {
|
||||
unsetEditingPost: () => void;
|
||||
openModal: (input: ModalData<DialogProps>) => void;
|
||||
scrollPostListToBottom: () => void;
|
||||
runMessageWillBeUpdatedHooks: (newPost: Partial<Post>, oldPost: Post) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
export type Props = {
|
||||
@@ -233,12 +235,20 @@ const EditPost = ({editingPost, actions, canEditPost, config, channelId, draft,
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedPost = {
|
||||
let updatedPost = {
|
||||
message: editText,
|
||||
id: editingPost.postId,
|
||||
channel_id: editingPost.post.channel_id,
|
||||
};
|
||||
|
||||
const hookResult = await actions.runMessageWillBeUpdatedHooks(updatedPost, editingPost.post);
|
||||
if (hookResult.error && hookResult.error.message) {
|
||||
setPostError(<>{hookResult.error.message}</>);
|
||||
return;
|
||||
}
|
||||
|
||||
updatedPost = hookResult.data;
|
||||
|
||||
if (postError) {
|
||||
setErrorClass('animation--highlight');
|
||||
setTimeout(() => setErrorClass(''), Constants.ANIMATION_TIMEOUT);
|
||||
|
||||
@@ -22,6 +22,7 @@ import {GlobalState} from 'types/store';
|
||||
import Constants, {RHSStates, StoragePrefixes} from 'utils/constants';
|
||||
import {setGlobalItem} from '../../actions/storage';
|
||||
import {getIsRhsOpen, getPostDraft, getRhsState} from '../../selectors/rhs';
|
||||
import {runMessageWillBeUpdatedHooks} from 'actions/hooks';
|
||||
|
||||
import EditPost, {Actions} from './edit_post';
|
||||
|
||||
@@ -67,6 +68,7 @@ function mapDispatchToProps(dispatch: Dispatch) {
|
||||
setDraft: setGlobalItem,
|
||||
unsetEditingPost,
|
||||
openModal,
|
||||
runMessageWillBeUpdatedHooks,
|
||||
}, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user