Skip to content

Commit

Permalink
feat: expose rebuild routes progress as a controller property
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Nov 30, 2023
1 parent 47e1059 commit 536f729
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/api/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,14 @@ readonly isRebuildingRoutes: boolean;

Returns whether the routes are currently being rebuilt for one or more nodes.

### `rebuildRoutesProgress`

```ts
readonly rebuildRoutesProgress: ReadonlyMap<number, RebuildRoutesStatus> | undefined;
```

If routes are currently being rebuilt for the entire network, this returns the current progress as a map of each node's ID and its status.

### `inclusionState`

```ts
Expand Down
17 changes: 17 additions & 0 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,20 @@ supported CCs: ${
}

private _rebuildRoutesProgress = new Map<number, RebuildRoutesStatus>();
/**
* If routes are currently being rebuilt for the entire network, this returns the current progress.
* The information is the same as in the `"rebuild routes progress"` event.
*/
public get rebuildRoutesProgress():
| ReadonlyMap<
number,
RebuildRoutesStatus
>
| undefined
{
if (!this._isRebuildingRoutes) return undefined;
return new Map(this._rebuildRoutesProgress);
}

/**
* Starts the process of rebuilding routes for all alive nodes in the network,
Expand Down Expand Up @@ -4053,6 +4067,7 @@ supported CCs: ${
}
// We're done!
this._isRebuildingRoutes = false;
this._rebuildRoutesProgress.clear();
}

/**
Expand All @@ -4073,6 +4088,8 @@ supported CCs: ${
|| t.message instanceof AssignReturnRouteRequest,
);

this._rebuildRoutesProgress.clear();

return true;
}

Expand Down

0 comments on commit 536f729

Please sign in to comment.