plan: fix stats re-registration ordering after config change
This commit is contained in:
@@ -798,9 +798,16 @@ type InflightSettings = CfgSettings & {
|
|||||||
state.unwatchStats = undefined;
|
state.unwatchStats = undefined;
|
||||||
```
|
```
|
||||||
|
|
||||||
5. In `onDidReceiveSettings`, after `state.settings = ev.payload.settings;`, add re-registration:
|
5. In `onDidReceiveSettings`, the re-registration must come AFTER
|
||||||
|
`runtime.ensureConnections(...)` (config changes recreate the
|
||||||
|
`StatsCache`, so registering earlier would land on the stale cache).
|
||||||
|
Change the tail of the method to:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
state.settings = ev.payload.settings;
|
||||||
|
state.action = ev.action;
|
||||||
|
state.history = [];
|
||||||
|
runtime.ensureConnections(cfgFromSettings(state.settings));
|
||||||
state.unwatchStats?.();
|
state.unwatchStats?.();
|
||||||
state.unwatchStats = undefined;
|
state.unwatchStats = undefined;
|
||||||
if (this.displayOf(state) === "usage") {
|
if (this.displayOf(state) === "usage") {
|
||||||
@@ -808,6 +815,7 @@ type InflightSettings = CfgSettings & {
|
|||||||
} else if (!state.sampler) {
|
} else if (!state.sampler) {
|
||||||
state.sampler = setInterval(() => this.sample(state), 1000);
|
state.sampler = setInterval(() => this.sample(state), 1000);
|
||||||
}
|
}
|
||||||
|
this.render(state);
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Replace `render` with a mode-switching version and add helpers:
|
6. Replace `render` with a mode-switching version and add helpers:
|
||||||
|
|||||||
Reference in New Issue
Block a user