mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +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:
parent
433d26e703
commit
6418b0c634
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user