Remove telemetry data cache if a telemetry endpoint is removed (#2916)

This commit is contained in:
Shefali Joshi 2020-04-10 16:49:29 -07:00 committed by GitHub
parent 1842d3923c
commit 7dd81beb03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -57,7 +57,6 @@ export default class ConditionManager extends EventEmitter {
endpoint,
this.telemetryReceived.bind(this, id)
);
// TODO check if this is needed
this.updateConditionTelemetry();
}
@ -71,6 +70,7 @@ export default class ConditionManager extends EventEmitter {
this.subscriptions[id]();
delete this.subscriptions[id];
delete this.telemetryObjects[id];
this.updateConditionTelemetry();
}
initialize() {

View File

@ -47,6 +47,21 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
updateTelemetry(telemetryObjects) {
this.telemetryObjects = { ...telemetryObjects };
this.removeTelemetryDataCache();
}
removeTelemetryDataCache() {
const telemetryCacheIds = Object.keys(this.telemetryDataCache);
Object.values(this.telemetryObjects).forEach(telemetryObject => {
const id = this.openmct.objects.makeKeyString(telemetryObject.identifier);
const foundIndex = telemetryCacheIds.indexOf(id);
if (foundIndex > -1) {
telemetryCacheIds.splice(foundIndex, 1);
}
});
telemetryCacheIds.forEach(id => {
delete (this.telemetryDataCache[id]);
});
}
formatData(data, telemetryObjects) {