Skip to content

Commit 89e6776

Browse files
author
Akos Kitta
committed
fix: remove double fds watcher
mark all nested files as a root change Signed-off-by: Akos Kitta <[email protected]>
1 parent 184a139 commit 89e6776

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

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

+7-22
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import { AuthenticationClientService } from '../../auth/authentication-client-se
1111
import { SketchbookTreeModel } from '../sketchbook/sketchbook-tree-model';
1212
import { WorkspaceNode } from '@theia/navigator/lib/browser/navigator-tree';
1313
import { CreateUri } from '../../create/create-uri';
14-
import {
15-
FileChangesEvent,
16-
FileChangeType,
17-
FileStat,
18-
} from '@theia/filesystem/lib/common/files';
14+
import { FileChangesEvent, FileStat } from '@theia/filesystem/lib/common/files';
1915
import {
2016
LocalCacheFsProvider,
2117
LocalCacheUri,
@@ -24,7 +20,6 @@ import URI from '@theia/core/lib/common/uri';
2420
import { SketchCache } from './cloud-sketch-cache';
2521
import { Create } from '../../create/typings';
2622
import { nls } from '@theia/core/lib/common/nls';
27-
import { DisposableCollection } from '@theia/core/lib/common/disposable';
2823
import { Deferred } from '@theia/core/lib/common/promise-util';
2924

3025
export function sketchBaseDir(sketch: Create.Sketch): FileStat {
@@ -72,24 +67,14 @@ export class CloudSketchbookTreeModel extends SketchbookTreeModel {
7267
@inject(SketchCache)
7368
private readonly sketchCache: SketchCache;
7469

75-
private readonly toDisposeOnSessionDidChange = new DisposableCollection();
7670
private _localCacheFsProviderReady: Deferred<void> | undefined;
7771

7872
@postConstruct()
7973
protected override init(): void {
8074
super.init();
8175
this.toDispose.push(
82-
this.authenticationService.onSessionDidChange((session) => {
83-
this.updateRoot();
84-
this.toDisposeOnSessionDidChange.dispose();
85-
if (session) {
86-
this.toDisposeOnSessionDidChange.push(
87-
this.fileService.watch(CreateUri.root)
88-
);
89-
}
90-
})
76+
this.authenticationService.onSessionDidChange(() => this.updateRoot())
9177
);
92-
this.ensureLocalFsProviderReady();
9378
}
9479

9580
override *getNodesByUri(uri: URI): IterableIterator<TreeNode> {
@@ -119,11 +104,11 @@ export class CloudSketchbookTreeModel extends SketchbookTreeModel {
119104
}
120105

121106
protected override isRootAffected(changes: FileChangesEvent): boolean {
122-
return changes.changes.some(
123-
(change) =>
124-
change.type === FileChangeType.ADDED &&
125-
change.resource.parent.toString() === LocalCacheUri.root.toString()
126-
);
107+
return changes.changes
108+
.map(({ resource }) => resource)
109+
.some(
110+
(uri) => uri.parent.toString().startsWith(LocalCacheUri.root.toString()) // all files under the root might effect the tree
111+
);
127112
}
128113

129114
override async refresh(

0 commit comments

Comments
 (0)