Set correct hasChanged and set it on all entry persistence actions

This commit is contained in:
Benaiah Mischenko 2017-03-16 11:18:43 -07:00
parent c8b9f2930e
commit 3adb1ee4fc
3 changed files with 6 additions and 4 deletions

View File

@ -241,8 +241,8 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
kind: 'success', kind: 'success',
dismissAfter: 4000, dismissAfter: 4000,
})); }));
dispatch(closeEntry());
dispatch(unpublishedEntryPersisted(collection, entry, transactionID)); dispatch(unpublishedEntryPersisted(collection, entry, transactionID));
dispatch(closeEntry());
}) })
.catch((error) => { .catch((error) => {
dispatch(notifSend({ dispatch(notifSend({

View File

@ -243,8 +243,8 @@ export function persistEntry(collection) {
kind: 'success', kind: 'success',
dismissAfter: 4000, dismissAfter: 4000,
})); }));
dispatch(closeEntry(collection));
dispatch(entryPersisted(collection, entry)); dispatch(entryPersisted(collection, entry));
dispatch(closeEntry(collection));
}) })
.catch((error) => { .catch((error) => {
dispatch(notifSend({ dispatch(notifSend({

View File

@ -37,6 +37,7 @@ const entryDraftReducer = (state = Map(), action) => {
state.set('mediaFiles', List()); state.set('mediaFiles', List());
state.set('fieldsMetaData', Map()); state.set('fieldsMetaData', Map());
state.set('fieldsErrors', Map()); state.set('fieldsErrors', Map());
state.set('hasChanged', false);
}); });
case DRAFT_CREATE_EMPTY: case DRAFT_CREATE_EMPTY:
// New Entry // New Entry
@ -46,6 +47,7 @@ const entryDraftReducer = (state = Map(), action) => {
state.set('mediaFiles', List()); state.set('mediaFiles', List());
state.set('fieldsMetaData', Map()); state.set('fieldsMetaData', Map());
state.set('fieldsErrors', Map()); state.set('fieldsErrors', Map());
state.set('hasChanged', false);
}); });
case DRAFT_DISCARD: case DRAFT_DISCARD:
return initialState; return initialState;
@ -68,16 +70,16 @@ const entryDraftReducer = (state = Map(), action) => {
return state.setIn(['entry', 'isPersisting'], true); return state.setIn(['entry', 'isPersisting'], true);
} }
case ENTRY_PERSIST_SUCCESS:
case ENTRY_PERSIST_FAILURE: case ENTRY_PERSIST_FAILURE:
case UNPUBLISHED_ENTRY_PERSIST_FAILURE: { case UNPUBLISHED_ENTRY_PERSIST_FAILURE: {
return state.deleteIn(['entry', 'isPersisting']); return state.deleteIn(['entry', 'isPersisting']);
} }
case ENTRY_PERSIST_SUCCESS:
case UNPUBLISHED_ENTRY_PERSIST_SUCCESS: case UNPUBLISHED_ENTRY_PERSIST_SUCCESS:
return state.withMutations((state) => { return state.withMutations((state) => {
state.deleteIn(['entry', 'isPersisting']); state.deleteIn(['entry', 'isPersisting']);
state.setIn(['entry', 'hasChanged'], false); state.set('hasChanged', false);
}); });
case ADD_ASSET: case ADD_ASSET: