Ensures the conditionManager is in sync with outside changes so that composition is not thrown away.

This commit is contained in:
Joshi 2020-03-13 14:08:14 -07:00
parent 09bfd80f69
commit 76e7fec1a0
3 changed files with 15 additions and 9 deletions

View File

@ -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() {

View File

@ -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() {

View File

@ -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) {