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: '',
|
||||
fileInfos: [],
|
||||
uploadsInProgress: [],
|
||||
metadata: {},
|
||||
}));
|
||||
|
||||
expect(store.getActions()).toEqual(testStore.getActions());
|
||||
|
||||
@@ -73,7 +73,7 @@ export function removeDraft(key: string, channelId: string, rootId = ''): Action
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
dispatch(setGlobalItem(key, {message: '', fileInfos: [], uploadsInProgress: []}));
|
||||
dispatch(setGlobalItem(key, {message: '', fileInfos: [], uploadsInProgress: [], metadata: {}}));
|
||||
|
||||
if (syncedDraftsAreAllowedAndEnabled(state)) {
|
||||
const connectionId = getConnectionId(getState());
|
||||
|
||||
@@ -13,7 +13,6 @@ import {savePreferences} from 'mattermost-redux/actions/preferences';
|
||||
import {Permissions} from 'mattermost-redux/constants';
|
||||
import {getChannel, makeGetChannel, getDirectChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
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 {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentUserId, isCurrentUserGuestUser, getStatusForUserId, makeGetDisplayName} from 'mattermost-redux/selectors/entities/users';
|
||||
@@ -143,7 +142,6 @@ const AdvancedTextEditor = ({
|
||||
return name;
|
||||
};
|
||||
|
||||
const post = useSelector((state: GlobalState) => getPost(state, postId));
|
||||
const currentUserId = useSelector(getCurrentUserId);
|
||||
const channel = useSelector((state: GlobalState) => getChannelSelector(state, channelId));
|
||||
const channelDisplayName = channel?.display_name || '';
|
||||
@@ -338,12 +336,17 @@ const AdvancedTextEditor = ({
|
||||
);
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
// This resets the draft to the post's original content
|
||||
handleDraftChange({
|
||||
...draft,
|
||||
message: post?.message || '',
|
||||
message: '',
|
||||
fileInfos: [],
|
||||
uploadsInProgress: [],
|
||||
createAt: 0,
|
||||
updateAt: 0,
|
||||
channelId,
|
||||
rootId: postId,
|
||||
metadata: {},
|
||||
});
|
||||
}, [handleDraftChange, draft, post]);
|
||||
}, [handleDraftChange, channelId, postId]);
|
||||
|
||||
const handleSubmitWrapper = useCallback(() => {
|
||||
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 {ensureString} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
import {removeDraft} from 'actions/views/drafts';
|
||||
import {getConnectionId} from 'selectors/general';
|
||||
|
||||
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 WithTooltip from 'components/with_tooltip';
|
||||
|
||||
import {ModalIdentifiers} from 'utils/constants';
|
||||
import {ModalIdentifiers, StoragePrefixes} from 'utils/constants';
|
||||
import {imageURLForUser} from 'utils/utils';
|
||||
|
||||
import RestorePostModal from '../restore_post_modal';
|
||||
@@ -123,6 +124,9 @@ const EditedPostItem = ({post, isCurrent = false, postCurrentVersion, theme, act
|
||||
actions.closeRightHandSide();
|
||||
showInfoTooltip();
|
||||
}
|
||||
|
||||
const key = StoragePrefixes.EDIT_DRAFT + post.original_id;
|
||||
dispatch(removeDraft(key, post.channel_id, post.root_id));
|
||||
};
|
||||
|
||||
const handleUndo = async () => {
|
||||
|
||||
Ссылка в новой задаче
Block a user