fix: duplicate and new entry action (#3003)
* fix: duplicate and new entry action * test(e2e): flush clock when duplicating entry to handle debounced fields Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
This commit is contained in:
@ -529,7 +529,7 @@ export function publishUnpublishedEntry(collection: string, slug: string) {
|
||||
);
|
||||
|
||||
dispatch(unpublishedEntryPublished(collection, slug, transactionID));
|
||||
dispatch(loadEntry(collections.get(collection), slug));
|
||||
return dispatch(loadEntry(collections.get(collection), slug));
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
dispatch(
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
import { ThunkDispatch } from 'redux-thunk';
|
||||
import { AnyAction, Dispatch } from 'redux';
|
||||
import { waitForMediaLibraryToLoad } from './mediaLibrary';
|
||||
import { waitUntil } from './waitUntil';
|
||||
|
||||
const { notifSend } = notifActions;
|
||||
|
||||
@ -215,7 +216,7 @@ export function createDraftFromEntry(entry: EntryMap, metadata?: Map<string, unk
|
||||
};
|
||||
}
|
||||
|
||||
export function createDraftDuplicateFromEntry(entry: EntryMap) {
|
||||
export function draftDuplicateEntry(entry: EntryMap) {
|
||||
return {
|
||||
type: DRAFT_CREATE_DUPLICATE_FROM_ENTRY,
|
||||
payload: createEntry(entry.get('collection'), '', '', { data: entry.get('data') }),
|
||||
@ -277,6 +278,17 @@ export function persistLocalBackup(entry: EntryMap, collection: Collection) {
|
||||
};
|
||||
}
|
||||
|
||||
export function createDraftDuplicateFromEntry(entry: EntryMap) {
|
||||
return (dispatch: ThunkDispatch<State, {}, AnyAction>) => {
|
||||
dispatch(
|
||||
waitUntil({
|
||||
predicate: ({ type }) => type === DRAFT_CREATE_EMPTY,
|
||||
run: () => dispatch(draftDuplicateEntry(entry)),
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function retrieveLocalBackup(collection: Collection, slug: string) {
|
||||
return async (dispatch: ThunkDispatch<State, {}, AnyAction>, getState: () => State) => {
|
||||
const state = getState();
|
||||
|
@ -318,10 +318,10 @@ export class Editor extends React.Component {
|
||||
return navigateToCollection(collection.get('name'));
|
||||
};
|
||||
|
||||
handleDuplicateEntry = async () => {
|
||||
handleDuplicateEntry = () => {
|
||||
const { createDraftDuplicateFromEntry, collection, entryDraft } = this.props;
|
||||
|
||||
await navigateToNewEntry(collection.get('name'));
|
||||
navigateToNewEntry(collection.get('name'));
|
||||
createDraftDuplicateFromEntry(entryDraft.get('entry'));
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user