100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI bug fixes for event subscriptions
Rich Turnerda4597f69a7f
diff --git a/ui/app/or-app/src/pages/page-map.ts b/ui/app/or-app/src/pages/page-map.tsindex c079a2eb9..764eb4de5 100644--- a/ui/app/or-app/src/pages/page-map.ts+++ b/ui/app/or-app/src/pages/page-map.ts@@ -129,11 +129,23 @@ const subscribeAssets = (): ThunkAction<void, MapStateKeyed, unknown, Action<strconst assetSubscriptionId = await manager.events.subscribeAssetEvents(ids, true, (event) => {dispatch(assetEventReceived(event));});++ if (!this.isConnected) {+ manager.events.unsubscribe(assetSubscriptionId);+ return;+ }+dispatch(setAssetSubscriptionId(assetSubscriptionId));const attributeSubscriptionId = await manager.events.subscribeAttributeEvents(ids, false, (event) => {dispatch(attributeEventReceived(event));});++ if (!this.isConnected) {+ manager.events.unsubscribe(attributeSubscriptionId);+ return;+ }+dispatch(setAttributeSubscriptionId(attributeSubscriptionId));}diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.tsindex af09e2b67..793ff37c1 100644--- a/ui/component/core/src/event.ts+++ b/ui/component/core/src/event.ts@@ -350,6 +350,17 @@ abstract class EventProviderImpl implements EventProvider {return;}+ // Keep cached asset in sync+ if (assetSubscription.asset) {+ if (evt.attributeState!.deleted) {+ delete assetSubscription.asset.attributes![evt.attributeState!.attributeRef!.attributeName!];+ } else {+ const attr = assetSubscription.asset.attributes![evt.attributeState!.attributeRef!.attributeName!] as Attribute;+ attr.value = evt.attributeState!.value;+ attr.valueTimestamp = evt.timestamp;+ }+ }+assetSubscription.callbacks.forEach((cb, key) => {cb(evt);});