Fix error when closing MRVA webview during extension activation
This fixes the "Webview is disposed" error which occurs when the user closes the variant analysis webview while the extension is still activating. We will now check whether the webview is disposed before restoring the view.
This commit is contained in:
@@ -37,6 +37,14 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
|
||||
return;
|
||||
}
|
||||
|
||||
// Between the time the webview is deserialized and the time the extension
|
||||
// is fully activated, the user may close the webview. In this case, we
|
||||
// should not attempt to restore the view.
|
||||
let disposed = false;
|
||||
const unregisterOnDidDispose = webviewPanel.onDidDispose(() => {
|
||||
disposed = true;
|
||||
});
|
||||
|
||||
const variantAnalysisState: VariantAnalysisState =
|
||||
state as VariantAnalysisState;
|
||||
|
||||
@@ -46,11 +54,16 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
|
||||
variantAnalysisState.variantAnalysisId,
|
||||
);
|
||||
if (existingView) {
|
||||
unregisterOnDidDispose.dispose();
|
||||
await existingView.openView();
|
||||
webviewPanel.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const view = new VariantAnalysisView(
|
||||
this.ctx,
|
||||
this.app,
|
||||
@@ -58,6 +71,8 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
|
||||
manager,
|
||||
);
|
||||
await view.restoreView(webviewPanel);
|
||||
|
||||
unregisterOnDidDispose.dispose();
|
||||
}
|
||||
|
||||
private waitForExtensionFullyLoaded(): Promise<
|
||||
|
||||
Reference in New Issue
Block a user