Skip to content

Commit

Permalink
Merge pull request #507 from netlify/fix-post-save-error
Browse files Browse the repository at this point in the history
Fix runtime error on saving post in editorial workflow
  • Loading branch information
erquhart authored Aug 17, 2017
2 parents 212d9d6 + fda2f22 commit 14be00b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/actions/editorialWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
const entryDraft = state.entryDraft;

// Early return if draft contains validation errors
if (!entryDraft.get('fieldsErrors').isEmpty()) return;
if (!entryDraft.get('fieldsErrors').isEmpty()) return Promise.resolve();

const backend = currentBackend(state.config);
const assetProxies = entryDraft.get('mediaFiles').map(path => getAsset(state, path));
Expand All @@ -234,23 +234,22 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {

dispatch(unpublishedEntryPersisting(collection, entry, transactionID));
const persistAction = existingUnpublishedEntry ? backend.persistUnpublishedEntry : backend.persistEntry;
persistAction.call(backend, state.config, collection, entryDraft, assetProxies.toJS())
return persistAction.call(backend, state.config, collection, entryDraft, assetProxies.toJS())
.then(() => {
dispatch(notifSend({
message: 'Entry saved',
kind: 'success',
dismissAfter: 4000,
}));
dispatch(unpublishedEntryPersisted(collection, entry, transactionID));
dispatch(closeEntry());
return dispatch(unpublishedEntryPersisted(collection, entry, transactionID));
})
.catch((error) => {
dispatch(notifSend({
message: `Failed to persist entry: ${ error }`,
kind: 'danger',
dismissAfter: 8000,
}));
dispatch(unpublishedEntryPersistedFail(error, transactionID));
return dispatch(unpublishedEntryPersistedFail(error, transactionID));
});
};
}
Expand Down

0 comments on commit 14be00b

Please sign in to comment.