Fix remote clock subscription (#6919)

* If there are no listeners for this clock then don't bother subscribing after getting the domain object details

* Comment explaining the fix
This commit is contained in:
Shefali Joshi 2023-08-14 14:51:52 -07:00 committed by GitHub
parent 57743e5918
commit c53073b339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,13 @@ export default class RemoteClock extends DefaultClock {
this.openmct.objects
.get(this.identifier)
.then((domainObject) => {
// The start method is called when at least one listener registers with the clock.
// When the clock is changed, listeners are unregistered from the clock and the stop method is called.
// Sometimes, the objects.get call above does not resolve before the stop method is called.
// So when we proceed with the clock subscription below, we first need to ensure that there is at least one listener for our clock.
if (this.eventNames().length === 0) {
return;
}
this.openmct.time.on('timeSystem', this._timeSystemChange);
this.timeTelemetryObject = domainObject;
this.metadata = this.openmct.telemetry.getMetadata(domainObject);