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