Skip to content

Commit b1025e8

Browse files
CopilotrobertsLando
andcommitted
fix(backend): store multicast group instances locally in map
- Add _multicastGroups Map<number, any> to store multicast group instances - Store multicast group instance when creating virtual node - Clean up stored instances when deleting groups - Addresses code review feedback to store instances locally Addresses review comment 2359460746. Co-authored-by: robertsLando <11502495+robertsLando@users.noreply.github.com>
1 parent 4151996 commit b1025e8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

api/lib/ZwaveClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
707707
private scenes: ZUIScene[]
708708
private groups: Group[]
709709
private _nodes: Map<number, ZUINode>
710+
private _multicastGroups: Map<number, any>
710711
private storeNodes: Record<number, Partial<ZUINode>>
711712
private _devices: Record<string, Partial<ZUINode>>
712713
private driverInfo: ZUIDriverInfo
@@ -833,6 +834,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
833834
this.groups = jsonStore.get(store.groups)
834835

835836
this._nodes = new Map()
837+
this._multicastGroups = new Map()
836838

837839
this._devices = {}
838840
this.driverInfo = {}
@@ -2911,6 +2913,9 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
29112913
// Remove virtual node
29122914
this._nodes.delete(id)
29132915

2916+
// Remove stored multicast group instance
2917+
this._multicastGroups.delete(id)
2918+
29142919
this.groups.splice(groupIndex, 1)
29152920
await jsonStore.put(store.groups, this.groups)
29162921

@@ -2934,8 +2939,9 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
29342939
if (!this.driverReady) return
29352940

29362941
try {
2937-
// Create virtual node (we don't need to use the multicastGroup object directly)
2938-
this._driver.controller.getMulticastGroup(group.nodeIds)
2942+
// Create and store the multicast group instance
2943+
const multicastGroup = this._driver.controller.getMulticastGroup(group.nodeIds)
2944+
this._multicastGroups.set(group.id, multicastGroup)
29392945

29402946
const virtualNode: ZUINode = {
29412947
id: group.id,

0 commit comments

Comments
 (0)