Edit post restore fix (#29851)
* Fix draft restore and cleanup * lint fix * Fixed a test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3a8d3fa38f
Коммит
4fc179137d
@@ -172,6 +172,7 @@ describe('draft actions', () => {
|
|||||||
message: '',
|
message: '',
|
||||||
fileInfos: [],
|
fileInfos: [],
|
||||||
uploadsInProgress: [],
|
uploadsInProgress: [],
|
||||||
|
metadata: {},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(store.getActions()).toEqual(testStore.getActions());
|
expect(store.getActions()).toEqual(testStore.getActions());
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export function removeDraft(key: string, channelId: string, rootId = ''): Action
|
|||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
||||||
dispatch(setGlobalItem(key, {message: '', fileInfos: [], uploadsInProgress: []}));
|
dispatch(setGlobalItem(key, {message: '', fileInfos: [], uploadsInProgress: [], metadata: {}}));
|
||||||
|
|
||||||
if (syncedDraftsAreAllowedAndEnabled(state)) {
|
if (syncedDraftsAreAllowedAndEnabled(state)) {
|
||||||
const connectionId = getConnectionId(getState());
|
const connectionId = getConnectionId(getState());
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {savePreferences} from 'mattermost-redux/actions/preferences';
|
|||||||
import {Permissions} from 'mattermost-redux/constants';
|
import {Permissions} from 'mattermost-redux/constants';
|
||||||
import {getChannel, makeGetChannel, getDirectChannel} from 'mattermost-redux/selectors/entities/channels';
|
import {getChannel, makeGetChannel, getDirectChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||||
import {getConfig, getFeatureFlagValue} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig, getFeatureFlagValue} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
|
||||||
import {get, getBool, getInt} from 'mattermost-redux/selectors/entities/preferences';
|
import {get, getBool, getInt} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
|
import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||||
import {getCurrentUserId, isCurrentUserGuestUser, getStatusForUserId, makeGetDisplayName} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUserId, isCurrentUserGuestUser, getStatusForUserId, makeGetDisplayName} from 'mattermost-redux/selectors/entities/users';
|
||||||
@@ -143,7 +142,6 @@ const AdvancedTextEditor = ({
|
|||||||
return name;
|
return name;
|
||||||
};
|
};
|
||||||
|
|
||||||
const post = useSelector((state: GlobalState) => getPost(state, postId));
|
|
||||||
const currentUserId = useSelector(getCurrentUserId);
|
const currentUserId = useSelector(getCurrentUserId);
|
||||||
const channel = useSelector((state: GlobalState) => getChannelSelector(state, channelId));
|
const channel = useSelector((state: GlobalState) => getChannelSelector(state, channelId));
|
||||||
const channelDisplayName = channel?.display_name || '';
|
const channelDisplayName = channel?.display_name || '';
|
||||||
@@ -338,12 +336,17 @@ const AdvancedTextEditor = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleCancel = useCallback(() => {
|
const handleCancel = useCallback(() => {
|
||||||
// This resets the draft to the post's original content
|
|
||||||
handleDraftChange({
|
handleDraftChange({
|
||||||
...draft,
|
message: '',
|
||||||
message: post?.message || '',
|
fileInfos: [],
|
||||||
|
uploadsInProgress: [],
|
||||||
|
createAt: 0,
|
||||||
|
updateAt: 0,
|
||||||
|
channelId,
|
||||||
|
rootId: postId,
|
||||||
|
metadata: {},
|
||||||
});
|
});
|
||||||
}, [handleDraftChange, draft, post]);
|
}, [handleDraftChange, channelId, postId]);
|
||||||
|
|
||||||
const handleSubmitWrapper = useCallback(() => {
|
const handleSubmitWrapper = useCallback(() => {
|
||||||
const isEmptyPost = isPostDraftEmpty(draft);
|
const isEmptyPost = isPostDraftEmpty(draft);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {getPostEditHistory, restorePostVersion} from 'mattermost-redux/actions/p
|
|||||||
import type {Theme} from 'mattermost-redux/selectors/entities/preferences';
|
import type {Theme} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {ensureString} from 'mattermost-redux/utils/post_utils';
|
import {ensureString} from 'mattermost-redux/utils/post_utils';
|
||||||
|
|
||||||
|
import {removeDraft} from 'actions/views/drafts';
|
||||||
import {getConnectionId} from 'selectors/general';
|
import {getConnectionId} from 'selectors/general';
|
||||||
|
|
||||||
import CompassThemeProvider from 'components/compass_theme_provider/compass_theme_provider';
|
import CompassThemeProvider from 'components/compass_theme_provider/compass_theme_provider';
|
||||||
@@ -25,7 +26,7 @@ import UserProfileComponent from 'components/user_profile';
|
|||||||
import Avatar from 'components/widgets/users/avatar';
|
import Avatar from 'components/widgets/users/avatar';
|
||||||
import WithTooltip from 'components/with_tooltip';
|
import WithTooltip from 'components/with_tooltip';
|
||||||
|
|
||||||
import {ModalIdentifiers} from 'utils/constants';
|
import {ModalIdentifiers, StoragePrefixes} from 'utils/constants';
|
||||||
import {imageURLForUser} from 'utils/utils';
|
import {imageURLForUser} from 'utils/utils';
|
||||||
|
|
||||||
import RestorePostModal from '../restore_post_modal';
|
import RestorePostModal from '../restore_post_modal';
|
||||||
@@ -123,6 +124,9 @@ const EditedPostItem = ({post, isCurrent = false, postCurrentVersion, theme, act
|
|||||||
actions.closeRightHandSide();
|
actions.closeRightHandSide();
|
||||||
showInfoTooltip();
|
showInfoTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const key = StoragePrefixes.EDIT_DRAFT + post.original_id;
|
||||||
|
dispatch(removeDraft(key, post.channel_id, post.root_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUndo = async () => {
|
const handleUndo = async () => {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user