Skip to content

Commit

Permalink
feat: add ondid resolve chldren event
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaaaash committed Jan 8, 2025
1 parent 7a5e058 commit c820a87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Autowired, Injectable } from '@opensumi/di';
import { ITree } from '@opensumi/ide-components';
import { CorePreferences, EDITOR_COMMANDS } from '@opensumi/ide-core-browser';
import { CommandService, URI, formatLocalize, localize, path } from '@opensumi/ide-core-common';
import { CommandService, Emitter, Event, URI, formatLocalize, localize, path } from '@opensumi/ide-core-common';
import { FileStat } from '@opensumi/ide-file-service';
import { IFileServiceClient } from '@opensumi/ide-file-service/lib/common';
import { IDialogService } from '@opensumi/ide-overlay';
Expand All @@ -12,6 +12,9 @@ import { Directory, File } from '../../common/file-tree-node.define';

@Injectable()
export class FileTreeAPI implements IFileTreeAPI {
private readonly onDidResolveChildrenEmitter: Emitter<string> = new Emitter();
onDidResolveChildren: Event<string> = this.onDidResolveChildrenEmitter.event;

@Autowired(IFileServiceClient)
protected fileServiceClient: IFileServiceClient;

Expand Down Expand Up @@ -44,6 +47,7 @@ export class FileTreeAPI implements IFileTreeAPI {
}

if (file) {
this.onDidResolveChildrenEmitter.fire(file.uri.toString());
if (file.children?.length === 1 && file.children[0].isDirectory && compact) {
return await this.resolveChildren(tree, file.children[0].uri, parent, compact);
} else {
Expand Down
4 changes: 3 additions & 1 deletion packages/file-tree-next/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ITree, ITreeNode } from '@opensumi/ide-components';
import { BasicEvent, IDisposable, URI } from '@opensumi/ide-core-common';
import { BasicEvent, Event, IDisposable, URI } from '@opensumi/ide-core-common';
import { FileStat } from '@opensumi/ide-file-service';

import { Directory, File } from './file-tree-node.define';
Expand All @@ -19,6 +19,8 @@ export interface IMoveFileMetadata {
}

export interface IFileTreeAPI {
onDidResolveChildren: Event<string>;

copyFile(from: URI, to: URI): Promise<FileStat | string | void>;
createFile(newUri: URI, content?: string): Promise<string | void>;
createDirectory(newUri: URI): Promise<string | void>;
Expand Down

0 comments on commit c820a87

Please sign in to comment.