mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 17:08:57 +00:00
[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:
@ -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;
|
||||
|
Reference in New Issue
Block a user