Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vscode): unregister listener if cloud onboarding webview is disposed #2316

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions libs/vscode/nx-cloud-view/src/lib/cloud-onboarding-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
CancellationToken,
commands,
Disposable,
ExtensionContext,
tasks,
Uri,
Expand All @@ -37,18 +38,18 @@ export class CloudOnboardingViewProvider implements WebviewViewProvider {
private _view: WebviewView | undefined;
private _webviewSourceUri: Uri;

private _refreshSubscription: Disposable;

constructor(private extensionContext: ExtensionContext) {
this._webviewSourceUri = Uri.joinPath(
this.extensionContext.extensionUri,
'nx-cloud-onboarding-webview'
);

const sub = onWorkspaceRefreshed(async () => {
this._refreshSubscription = onWorkspaceRefreshed(async () => {
await this.refresh();
});
if (sub) {
extensionContext.subscriptions.push(sub);
}
extensionContext.subscriptions.push(this._refreshSubscription);
}

async resolveWebviewView(
Expand All @@ -73,6 +74,10 @@ export class CloudOnboardingViewProvider implements WebviewViewProvider {
webviewView.webview.onDidReceiveMessage((event) => {
this.handleWebviewMessage(event);
});

webviewView.onDidDispose(() => {
this._refreshSubscription.dispose();
});
}

async refresh() {
Expand Down
Loading