From 3adb1ee4fc468915275ec41a17b1c9defa980648 Mon Sep 17 00:00:00 2001 From: Benaiah Mischenko Date: Thu, 16 Mar 2017 11:18:43 -0700 Subject: [PATCH] Set correct `hasChanged` and set it on all entry persistence actions --- src/actions/editorialWorkflow.js | 2 +- src/actions/entries.js | 2 +- src/reducers/entryDraft.js | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/actions/editorialWorkflow.js b/src/actions/editorialWorkflow.js index c1cc0ffa..3a03bd67 100644 --- a/src/actions/editorialWorkflow.js +++ b/src/actions/editorialWorkflow.js @@ -241,8 +241,8 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) { kind: 'success', dismissAfter: 4000, })); - dispatch(closeEntry()); dispatch(unpublishedEntryPersisted(collection, entry, transactionID)); + dispatch(closeEntry()); }) .catch((error) => { dispatch(notifSend({ diff --git a/src/actions/entries.js b/src/actions/entries.js index 22ffd848..7b57d8a3 100644 --- a/src/actions/entries.js +++ b/src/actions/entries.js @@ -243,8 +243,8 @@ export function persistEntry(collection) { kind: 'success', dismissAfter: 4000, })); - dispatch(closeEntry(collection)); dispatch(entryPersisted(collection, entry)); + dispatch(closeEntry(collection)); }) .catch((error) => { dispatch(notifSend({ diff --git a/src/reducers/entryDraft.js b/src/reducers/entryDraft.js index 0e76ef66..f8c8fc6f 100644 --- a/src/reducers/entryDraft.js +++ b/src/reducers/entryDraft.js @@ -37,6 +37,7 @@ const entryDraftReducer = (state = Map(), action) => { state.set('mediaFiles', List()); state.set('fieldsMetaData', Map()); state.set('fieldsErrors', Map()); + state.set('hasChanged', false); }); case DRAFT_CREATE_EMPTY: // New Entry @@ -46,6 +47,7 @@ const entryDraftReducer = (state = Map(), action) => { state.set('mediaFiles', List()); state.set('fieldsMetaData', Map()); state.set('fieldsErrors', Map()); + state.set('hasChanged', false); }); case DRAFT_DISCARD: return initialState; @@ -68,16 +70,16 @@ const entryDraftReducer = (state = Map(), action) => { return state.setIn(['entry', 'isPersisting'], true); } - case ENTRY_PERSIST_SUCCESS: case ENTRY_PERSIST_FAILURE: case UNPUBLISHED_ENTRY_PERSIST_FAILURE: { return state.deleteIn(['entry', 'isPersisting']); } + case ENTRY_PERSIST_SUCCESS: case UNPUBLISHED_ENTRY_PERSIST_SUCCESS: return state.withMutations((state) => { state.deleteIn(['entry', 'isPersisting']); - state.setIn(['entry', 'hasChanged'], false); + state.set('hasChanged', false); }); case ADD_ASSET: