Skip to content

Commit bd44b49

Browse files
author
Akos Kitta
committed
Restored the Settings UI. Deferred model loading.
Closes #1031 Signed-off-by: Akos Kitta <[email protected]>
1 parent fd5154a commit bd44b49

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Diff for: arduino-ide-extension/src/browser/theia/preferences/preference-tree-generator.ts

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
1+
import {
2+
FrontendApplicationState,
3+
FrontendApplicationStateService,
4+
} from '@theia/core/lib/browser/frontend-application-state';
15
import { CompositeTreeNode } from '@theia/core/lib/browser/tree/tree';
2-
import { injectable } from '@theia/core/shared/inversify';
6+
import { inject, injectable } from '@theia/core/shared/inversify';
37
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
48

59
@injectable()
610
export class PreferenceTreeGenerator extends TheiaPreferenceTreeGenerator {
11+
private shouldHandleChangedSchemaOnReady = false;
12+
private state: FrontendApplicationState | undefined;
13+
14+
@inject(FrontendApplicationStateService)
15+
private readonly appStateService: FrontendApplicationStateService;
16+
717
protected override async init(): Promise<void> {
8-
// The IDE2 does not use the default Theia preferences UI.
9-
// There is no need to create and keep the the tree model synchronized when there is no UI for it.
18+
this.appStateService.onStateChanged((state) => {
19+
this.state = state;
20+
// manually trigger a model (and UI) refresh if it was requested during the startup phase.
21+
if (this.state === 'ready' && this.shouldHandleChangedSchemaOnReady) {
22+
this.doHandleChangedSchema();
23+
}
24+
});
25+
return super.init();
26+
}
27+
28+
override doHandleChangedSchema(): void {
29+
if (this.state === 'ready') {
30+
super.doHandleChangedSchema();
31+
}
32+
// don't do anything until the app is `ready`, then invoke `doHandleChangedSchema`.
33+
this.shouldHandleChangedSchemaOnReady = true;
1034
}
1135

12-
// Just returns with the empty root.
1336
override generateTree(): CompositeTreeNode {
37+
if (this.state === 'ready') {
38+
return super.generateTree();
39+
}
40+
// always create an empty root when the app is not ready.
1441
this._root = this.createRootNode();
1542
return this._root;
1643
}

0 commit comments

Comments
 (0)