|
|
@ -1,15 +1,19 @@ |
|
|
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; |
|
|
|
import { Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; |
|
|
|
import type { RepositoriesChangeEvent } from '../../git/gitProviderService'; |
|
|
|
import { GitUri } from '../../git/gitUri'; |
|
|
|
import type { CloudWorkspace, LocalWorkspace } from '../../plus/workspaces/models'; |
|
|
|
import { WorkspaceType } from '../../plus/workspaces/models'; |
|
|
|
import { createCommand } from '../../system/command'; |
|
|
|
import { gate } from '../../system/decorators/gate'; |
|
|
|
import { debug } from '../../system/decorators/log'; |
|
|
|
import type { WorkspacesView } from '../workspacesView'; |
|
|
|
import { CommandMessageNode, MessageNode } from './common'; |
|
|
|
import { RepositoryNode } from './repositoryNode'; |
|
|
|
import { ContextValues, getViewNodeId, ViewNode } from './viewNode'; |
|
|
|
import type { ViewNode } from './viewNode'; |
|
|
|
import { ContextValues, getViewNodeId, SubscribeableViewNode } from './viewNode'; |
|
|
|
import { WorkspaceMissingRepositoryNode } from './workspaceMissingRepositoryNode'; |
|
|
|
|
|
|
|
export class WorkspaceNode extends ViewNode<WorkspacesView> { |
|
|
|
export class WorkspaceNode extends SubscribeableViewNode<WorkspacesView> { |
|
|
|
constructor( |
|
|
|
uri: GitUri, |
|
|
|
view: WorkspacesView, |
|
|
@ -22,6 +26,22 @@ export class WorkspaceNode extends ViewNode { |
|
|
|
this._uniqueId = getViewNodeId('workspace', this.context); |
|
|
|
} |
|
|
|
|
|
|
|
override dispose() { |
|
|
|
super.dispose(); |
|
|
|
this.resetChildren(); |
|
|
|
} |
|
|
|
|
|
|
|
private resetChildren() { |
|
|
|
if (this._children == null) return; |
|
|
|
|
|
|
|
for (const child of this._children) { |
|
|
|
if ('dispose' in child) { |
|
|
|
child.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
this._children = undefined; |
|
|
|
} |
|
|
|
|
|
|
|
override get id(): string { |
|
|
|
return this._uniqueId; |
|
|
|
} |
|
|
@ -131,17 +151,26 @@ export class WorkspaceNode extends ViewNode { |
|
|
|
return item; |
|
|
|
} |
|
|
|
|
|
|
|
override refresh() { |
|
|
|
@gate() |
|
|
|
@debug() |
|
|
|
override refresh(reset: boolean = false) { |
|
|
|
if (this._children == null) return; |
|
|
|
|
|
|
|
if (this._children.length) { |
|
|
|
for (const child of this._children) { |
|
|
|
if ('dispose' in child) { |
|
|
|
child.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (reset) { |
|
|
|
this.resetChildren(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this._children = undefined; |
|
|
|
protected override etag(): number { |
|
|
|
return this.view.container.git.etag; |
|
|
|
} |
|
|
|
|
|
|
|
@debug() |
|
|
|
protected subscribe(): Disposable | Promise<Disposable> { |
|
|
|
return Disposable.from(this.view.container.git.onDidChangeRepositories(this.onRepositoriesChanged, this)); |
|
|
|
} |
|
|
|
|
|
|
|
private onRepositoriesChanged(_e: RepositoriesChangeEvent) { |
|
|
|
void this.triggerChange(true); |
|
|
|
} |
|
|
|
} |