[Persistence] Avoid redundant calls to persistenceService

Mutation now triggers persistence; this means that some legacy code
does or may issue redundant calls to persistence after mutating.
To avoid issuing redundant calls all the way down to the
persistenceService, bail out of persist calls early if there are
no unsaved changes to persist.
This commit is contained in:
Victor Woeltjen 2016-04-26 16:58:10 -07:00
parent 433d26e703
commit 6418b0c634

View File

@ -132,12 +132,17 @@ define(
domainObject = this.domainObject,
model = domainObject.getModel(),
modified = model.modified,
persisted = model.persisted,
cacheService = this.cacheService,
persistenceService = this.persistenceService,
persistenceFn = model.persisted !== undefined ?
this.persistenceService.updateObject :
this.persistenceService.createObject;
if (persisted !== undefined && persisted === modified) {
return this.$q.when(true);
}
// Update persistence timestamp...
domainObject.useCapability("mutation", function (model) {
model.persisted = modified;