Close view when variant analyis is deleted from query history
This will close the variant analysis view when the corresponding variant analysis history item is deleted from the query history. This required some extra code to handle `dispose` being called on the view to ensure this actually disposes the panel, but we can now call `dispose()` on the view to close it.
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
} from 'vscode';
|
||||
import * as path from 'path';
|
||||
|
||||
import { DisposableObject } from './pure/disposable-object';
|
||||
import { DisposableObject, DisposeHandler } from './pure/disposable-object';
|
||||
import { tmpDir } from './helpers';
|
||||
import { getHtmlForWebview, WebviewMessage, WebviewView } from './interface-utils';
|
||||
|
||||
@@ -126,4 +126,9 @@ export abstract class AbstractWebview<ToMessage extends WebviewMessage, FromMess
|
||||
protected postMessage(msg: ToMessage): Thenable<boolean> {
|
||||
return this.getPanel().webview.postMessage(msg);
|
||||
}
|
||||
|
||||
public dispose(disposeHandler?: DisposeHandler) {
|
||||
this.panel?.dispose();
|
||||
super.dispose(disposeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import { createTimestampFile, showAndLogErrorMessage } from '../helpers';
|
||||
import { QueryStatus } from '../query-status';
|
||||
import * as fs from 'fs-extra';
|
||||
|
||||
|
||||
export class VariantAnalysisManager extends DisposableObject implements VariantAnalysisViewManager<VariantAnalysisView> {
|
||||
private readonly _onVariantAnalysisAdded = this.push(new EventEmitter<VariantAnalysis>());
|
||||
public readonly onVariantAnalysisAdded = this._onVariantAnalysisAdded.event;
|
||||
@@ -75,6 +74,9 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
this.variantAnalysisResultsManager.removeAnalysisResults(variantAnalysis);
|
||||
await this.removeStorageDirectory(variantAnalysis.id);
|
||||
this.variantAnalyses.delete(variantAnalysis.id);
|
||||
|
||||
// This will automatically unregister the view
|
||||
this.views.get(variantAnalysis.id)?.dispose();
|
||||
}
|
||||
|
||||
private async removeStorageDirectory(variantAnalysisId: number) {
|
||||
@@ -88,7 +90,7 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
}
|
||||
if (!this.views.has(variantAnalysisId)) {
|
||||
// The view will register itself with the manager, so we don't need to do anything here.
|
||||
this.push(new VariantAnalysisView(this.ctx, variantAnalysisId, this));
|
||||
this.track(new VariantAnalysisView(this.ctx, variantAnalysisId, this));
|
||||
}
|
||||
|
||||
const variantAnalysisView = this.views.get(variantAnalysisId)!;
|
||||
@@ -106,6 +108,7 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
|
||||
public unregisterView(view: VariantAnalysisView): void {
|
||||
this.views.delete(view.variantAnalysisId);
|
||||
this.disposeAndStopTracking(view);
|
||||
}
|
||||
|
||||
public getView(variantAnalysisId: number): VariantAnalysisView | undefined {
|
||||
|
||||
Reference in New Issue
Block a user