diff --git a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts index ddf5018a69..2d7c8af529 100644 --- a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts +++ b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts @@ -50,6 +50,7 @@ import { UnreadCountSubCmd, UnreadSubCmd, UnsubscribeCmd, + WebsocketCmd, WebsocketDataMsg } from '@app/shared/models/telemetry/telemetry.models'; import { Store } from '@ngrx/store'; @@ -94,11 +95,14 @@ export class TelemetryWebsocketService extends WebsocketService { if (subscriptionCommand.cmdId && (subscriptionCommand instanceof EntityDataCmd || subscriptionCommand instanceof UnreadSubCmd)) { + this.syncCommandId(subscriptionCommand, subscriber); this.cmdWrapper.cmds.push(subscriptionCommand); } } ); this.publishCommands(); + } else { + this.pendingUpdates.add(subscriber); } } @@ -177,4 +181,15 @@ export class TelemetryWebsocketService extends WebsocketService implements WsServ subscribersMap = new Map(); reconnectSubscribers = new Set(); + pendingUpdates = new Set(); wsUri: string; @@ -140,6 +141,7 @@ export abstract class WebsocketService implements WsServ if (close) { this.reconnectAttempts = 0; this.lastShownCloseCode = null; + this.pendingUpdates.clear(); this.closeSocket(); } } @@ -223,6 +225,7 @@ export abstract class WebsocketService implements WsServ } ); this.reconnectSubscribers.clear(); + this.processPendingUpdates(); } else { this.publishCommands(); } @@ -298,4 +301,13 @@ export abstract class WebsocketService implements WsServ message, type: notificationType })); } + + private processPendingUpdates() { + if (this.pendingUpdates.size > 0) { + this.pendingUpdates.forEach((subscriber) => { + this.update(subscriber); + }); + this.pendingUpdates.clear(); + } + } }