Skip to content

Commit e91ba86

Browse files
author
Akos Kitta
committed
fix: tree root updates when internet is back but root was never created
Signed-off-by: Akos Kitta <[email protected]>
1 parent 25665d8 commit e91ba86

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-tree-model.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import URI from '@theia/core/lib/common/uri';
2020
import { Create } from '../../create/typings';
2121
import { nls } from '@theia/core/lib/common/nls';
2222
import { Deferred } from '@theia/core/lib/common/promise-util';
23+
import { ApplicationConnectionStatusContribution } from '../../theia/core/connection-status-service';
2324

2425
function sketchBaseDir(sketch: Create.Sketch): FileStat {
2526
// extract the sketch path
@@ -63,15 +64,22 @@ export class CloudSketchbookTreeModel extends SketchbookTreeModel {
6364
private readonly authenticationService: AuthenticationClientService;
6465
@inject(LocalCacheFsProvider)
6566
private readonly localCacheFsProvider: LocalCacheFsProvider;
67+
@inject(ApplicationConnectionStatusContribution)
68+
private readonly connectionStatus: ApplicationConnectionStatusContribution;
6669

6770
private _localCacheFsProviderReady: Deferred<void> | undefined;
6871

6972
@postConstruct()
7073
protected override init(): void {
7174
super.init();
72-
this.toDispose.push(
73-
this.authenticationService.onSessionDidChange(() => this.updateRoot())
74-
);
75+
this.toDispose.pushAll([
76+
this.authenticationService.onSessionDidChange(() => this.updateRoot()),
77+
this.connectionStatus.onOfflineStatusDidChange((offlineStatus) => {
78+
if (!offlineStatus) {
79+
this.updateRoot();
80+
}
81+
}),
82+
]);
7583
}
7684

7785
override *getNodesByUri(uri: URI): IterableIterator<TreeNode> {

0 commit comments

Comments
 (0)