mirror of
https://github.com/nasa/openmct.git
synced 2025-02-24 02:41:25 +00:00
Ensures the conditionManager is in sync with outside changes so that composition is not thrown away.
This commit is contained in:
parent
09bfd80f69
commit
76e7fec1a0
@ -31,7 +31,6 @@ export default class ConditionManager extends EventEmitter {
|
||||
this.conditionSetDomainObject = conditionSetDomainObject;
|
||||
this.timeAPI = this.openmct.time;
|
||||
this.latestTimestamp = {};
|
||||
this.instantiate = this.openmct.$injector.get('instantiate');
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
@ -45,10 +44,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
//this should not happen very frequently
|
||||
update(newConditionCollection) {
|
||||
// this should not happen very frequently
|
||||
update(newDomainObject) {
|
||||
this.destroy();
|
||||
this.conditionSetDomainObject.configuration.conditionCollection = newConditionCollection;
|
||||
this.conditionSetDomainObject = newDomainObject;
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
@ -208,7 +207,14 @@ export default class ConditionManager extends EventEmitter {
|
||||
}
|
||||
|
||||
persistConditions() {
|
||||
this.openmct.objects.mutate(this.conditionSetDomainObject, 'configuration.conditionCollection', this.conditionSetDomainObject.configuration.conditionCollection);
|
||||
this.openmct.objects.get(this.conditionSetDomainObject.identifier).then((conditionSetDomainObject) => {
|
||||
let conditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
||||
//we want to keep our copy of the conditionSet domain object in sync
|
||||
this.conditionSetDomainObject = conditionSetDomainObject;
|
||||
//but we want to ensure that the conditionCollection we have is the latest
|
||||
this.conditionSetDomainObject.configuration.conditionCollection = conditionCollection;
|
||||
this.openmct.objects.mutate(this.conditionSetDomainObject, 'configuration.conditionCollection', this.conditionSetDomainObject.configuration.conditionCollection);
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
@ -43,8 +43,8 @@ export default class ConditionSetTelemetryProvider {
|
||||
let conditionManager = new ConditionManager(domainObject, this.openmct);
|
||||
conditionManager.on('conditionSetResultUpdated', callback);
|
||||
|
||||
let stopObservingForChanges = this.openmct.objects.observe(domainObject, 'configuration.conditionCollection', (newConditionCollection) => {
|
||||
conditionManager.update(newConditionCollection);
|
||||
let stopObservingForChanges = this.openmct.objects.observe(domainObject, '*', (newDomainObject) => {
|
||||
conditionManager.update(newDomainObject);
|
||||
});
|
||||
|
||||
return function unsubscribe() {
|
||||
|
@ -124,8 +124,8 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
observeForChanges() {
|
||||
this.stopObservingForChanges = this.openmct.objects.observe(this.domainObject, '*', (newDomainObject) => {
|
||||
this.conditionCollection = newDomainObject.configuration.conditionCollection;
|
||||
this.stopObservingForChanges = this.openmct.objects.observe(this.domainObject, 'configuration.conditionCollection', (newConditionCollection) => {
|
||||
this.conditionCollection = newConditionCollection;
|
||||
});
|
||||
},
|
||||
setMoveIndex(index) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user