From 84d1ede76ce5ea1f019708dc2b83de912262fe70 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 12 Jul 2023 18:28:20 -0400 Subject: [PATCH] Fixes node leaks from subscriptions --- src/views/nodes/repositoriesNode.ts | 2 +- src/views/nodes/workspaceNode.ts | 14 +++++++++++++- src/views/nodes/workspacesViewNode.ts | 10 ++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index 77db91a..d4ccb4b 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -168,6 +168,6 @@ export class RepositoriesNode extends SubscribeableViewNode { return this.workspace.name; } - private _children: ViewNode[] | undefined; + private _children: + | (CommandMessageNode | MessageNode | RepositoryNode | WorkspaceMissingRepositoryNode)[] + | undefined; async getChildren(): Promise { if (this._children == null) { @@ -130,6 +132,16 @@ export class WorkspaceNode extends ViewNode { } override refresh() { + if (this._children == null) return; + + if (this._children.length) { + for (const child of this._children) { + if ('dispose' in child) { + child.dispose(); + } + } + } + this._children = undefined; } } diff --git a/src/views/nodes/workspacesViewNode.ts b/src/views/nodes/workspacesViewNode.ts index b8668ac..3bb0214 100644 --- a/src/views/nodes/workspacesViewNode.ts +++ b/src/views/nodes/workspacesViewNode.ts @@ -55,6 +55,16 @@ export class WorkspacesViewNode extends ViewNode { @gate() @debug() override refresh() { + if (this._children == null) return; + + if (this._children.length) { + for (const child of this._children) { + if ('dispose' in child) { + child.dispose(); + } + } + } + this._children = undefined; } }