From 1d88b15de54d62d1d8d40a0391e9fc640af2ca97 Mon Sep 17 00:00:00 2001 From: Bartholomew Date: Thu, 9 Apr 2020 12:44:06 +0100 Subject: [PATCH] fix: duplicate entry (#3563) --- packages/netlify-cms-core/src/actions/editorialWorkflow.ts | 1 + packages/netlify-cms-core/src/actions/entries.ts | 1 + packages/netlify-cms-core/src/components/Editor/Editor.js | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/netlify-cms-core/src/actions/editorialWorkflow.ts b/packages/netlify-cms-core/src/actions/editorialWorkflow.ts index 312fd339..0fe730ac 100644 --- a/packages/netlify-cms-core/src/actions/editorialWorkflow.ts +++ b/packages/netlify-cms-core/src/actions/editorialWorkflow.ts @@ -406,6 +406,7 @@ export function persistUnpublishedEntry(collection: Collection, existingUnpublis }), ); dispatch(unpublishedEntryPersisted(collection, transactionID, newSlug)); + if (!existingUnpublishedEntry) return dispatch(loadUnpublishedEntry(collection, newSlug)); } catch (error) { dispatch( notifSend({ diff --git a/packages/netlify-cms-core/src/actions/entries.ts b/packages/netlify-cms-core/src/actions/entries.ts index 6bbdede5..8a73b1c5 100644 --- a/packages/netlify-cms-core/src/actions/entries.ts +++ b/packages/netlify-cms-core/src/actions/entries.ts @@ -762,6 +762,7 @@ export function persistEntry(collection: Collection) { dispatch(loadMedia()); } dispatch(entryPersisted(collection, serializedEntry, slug)); + if (serializedEntry.get('newRecord')) return dispatch(loadEntry(collection, slug)); }) .catch((error: Error) => { console.error(error); diff --git a/packages/netlify-cms-core/src/components/Editor/Editor.js b/packages/netlify-cms-core/src/components/Editor/Editor.js index f11f8bb0..dc54f83b 100644 --- a/packages/netlify-cms-core/src/components/Editor/Editor.js +++ b/packages/netlify-cms-core/src/components/Editor/Editor.js @@ -177,7 +177,6 @@ export class Editor extends React.Component { const newSlug = this.props.entryDraft && this.props.entryDraft.getIn(['entry', 'slug']); if (!prevProps.slug && newSlug && this.props.newEntry) { navigateToEntry(prevProps.collection.get('name'), newSlug); - this.props.loadEntry(this.props.collection, newSlug); } if (!prevProps.localBackup && this.props.localBackup) {