mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 05:38:12 +00:00
[Staleness] Fix staleness on clock change (#7088)
* Update staleness mixin * Fix listeners and add guard * Add check to make sure staleness only shows for correct clock * Add guard for time api * Cleanup the setting of isStale in ObjectView * Cleanup use of combinedKey on LadTableSet
This commit is contained in:
@ -55,6 +55,7 @@ define([
|
||||
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
|
||||
this.telemetryObjects = {};
|
||||
this.subscribedStaleObjects = new Map();
|
||||
this.telemetryCollections = {};
|
||||
this.delayedActions = [];
|
||||
this.outstandingRequests = 0;
|
||||
@ -74,6 +75,8 @@ define([
|
||||
this.filterObserver = undefined;
|
||||
|
||||
this.createTableRowCollections();
|
||||
this.resubscribeToStaleness = this.resubscribeAllObjectsToStaleness.bind(this);
|
||||
this.openmct.time.on('clockChanged', this.resubscribeToStaleness);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,24 +166,7 @@ define([
|
||||
this.telemetryCollections[keyString].on('clear', this.clearData);
|
||||
this.telemetryCollections[keyString].load();
|
||||
|
||||
this.stalenessSubscription[keyString] = {};
|
||||
this.stalenessSubscription[keyString].stalenessUtils = new StalenessUtils.default(
|
||||
this.openmct,
|
||||
telemetryObject
|
||||
);
|
||||
this.openmct.telemetry.isStale(telemetryObject).then((stalenessResponse) => {
|
||||
if (stalenessResponse !== undefined) {
|
||||
this.handleStaleness(keyString, stalenessResponse);
|
||||
}
|
||||
});
|
||||
const stalenessSubscription = this.openmct.telemetry.subscribeToStaleness(
|
||||
telemetryObject,
|
||||
(stalenessResponse) => {
|
||||
this.handleStaleness(keyString, stalenessResponse);
|
||||
}
|
||||
);
|
||||
|
||||
this.stalenessSubscription[keyString].unsubscribe = stalenessSubscription;
|
||||
this.subscribeToStaleness(telemetryObject);
|
||||
|
||||
this.telemetryObjects[keyString] = {
|
||||
telemetryObject,
|
||||
@ -193,6 +179,42 @@ define([
|
||||
this.emit('object-added', telemetryObject);
|
||||
}
|
||||
|
||||
resubscribeAllObjectsToStaleness() {
|
||||
if (!this.subscribedStaleObjects || this.subscribedStaleObjects.size < 1) {
|
||||
return;
|
||||
}
|
||||
for (const [, telemetryObject] of this.subscribedStaleObjects) {
|
||||
this.subscribeToStaleness(telemetryObject);
|
||||
}
|
||||
}
|
||||
|
||||
subscribeToStaleness(domainObject) {
|
||||
const keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||
if (this.stalenessSubscription?.[keyString]) {
|
||||
this.unsubscribeFromStaleness(domainObject.identifier);
|
||||
}
|
||||
|
||||
this.stalenessSubscription[keyString] = {};
|
||||
this.stalenessSubscription[keyString].stalenessUtils = new StalenessUtils.default(
|
||||
this.openmct,
|
||||
domainObject
|
||||
);
|
||||
this.openmct.telemetry.isStale(domainObject).then((stalenessResponse) => {
|
||||
if (stalenessResponse !== undefined) {
|
||||
this.handleStaleness(keyString, stalenessResponse);
|
||||
}
|
||||
});
|
||||
const stalenessSubscription = this.openmct.telemetry.subscribeToStaleness(
|
||||
domainObject,
|
||||
(stalenessResponse) => {
|
||||
this.handleStaleness(keyString, stalenessResponse);
|
||||
}
|
||||
);
|
||||
this.subscribedStaleObjects.set(keyString, domainObject);
|
||||
|
||||
this.stalenessSubscription[keyString].unsubscribe = stalenessSubscription;
|
||||
}
|
||||
|
||||
handleStaleness(keyString, stalenessResponse, skipCheck = false) {
|
||||
if (
|
||||
skipCheck ||
|
||||
@ -203,7 +225,7 @@ define([
|
||||
) {
|
||||
this.emit('telemetry-staleness', {
|
||||
keyString,
|
||||
isStale: stalenessResponse.isStale
|
||||
stalenessResponse: stalenessResponse
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -310,7 +332,6 @@ define([
|
||||
|
||||
removeTelemetryObject(objectIdentifier) {
|
||||
const keyString = this.openmct.objects.makeKeyString(objectIdentifier);
|
||||
const SKIP_CHECK = true;
|
||||
|
||||
this.configuration.removeColumnsForObject(objectIdentifier, true);
|
||||
this.tableRows.removeRowsByObject(keyString);
|
||||
@ -320,6 +341,13 @@ define([
|
||||
|
||||
this.emit('object-removed', objectIdentifier);
|
||||
|
||||
this.unsubscribeFromStaleness(objectIdentifier);
|
||||
}
|
||||
|
||||
unsubscribeFromStaleness(objectIdentifier) {
|
||||
const keyString = this.openmct.objects.makeKeyString(objectIdentifier);
|
||||
const SKIP_CHECK = true;
|
||||
|
||||
this.stalenessSubscription[keyString].unsubscribe();
|
||||
this.stalenessSubscription[keyString].stalenessUtils.destroy();
|
||||
this.handleStaleness(keyString, { isStale: false }, SKIP_CHECK);
|
||||
@ -423,6 +451,7 @@ define([
|
||||
this.tableRows.destroy();
|
||||
|
||||
this.tableRows.off('resetRowsFromAllData', this.resetRowsFromAllData);
|
||||
this.openmct.time.off('clockChanged', this.resubscribeToStaleness);
|
||||
|
||||
let keystrings = Object.keys(this.telemetryCollections);
|
||||
keystrings.forEach(this.removeTelemetryCollection);
|
||||
|
Reference in New Issue
Block a user