From 69312563f5e6c4c6b20483ff3da5a04f9c293701 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Tue, 3 Aug 2021 11:00:57 +0200 Subject: [PATCH] fix(Stats View): :bug: Close stats view on unload --- src/main.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 5dff8fc9..f21f7045 100644 --- a/src/main.ts +++ b/src/main.ts @@ -162,7 +162,7 @@ export default class BreadcrumbsPlugin extends Plugin { }, }); - this.addRibbonIcon("dice", "Make Adjacency Matrix", () => + this.addRibbonIcon("dice", "Breadcrumbs Visualisation", () => new VisModal(this.app, this).open() ); @@ -443,9 +443,13 @@ export default class BreadcrumbsPlugin extends Plugin { onunload(): void { console.log("unloading"); // Detach matrix view - const openLeaves = this.app.workspace.getLeavesOfType( - VIEW_TYPE_BREADCRUMBS_MATRIX - ); + const openLeaves = [ + VIEW_TYPE_BREADCRUMBS_MATRIX, + VIEW_TYPE_BREADCRUMBS_STATS, + ] + .map((type) => this.app.workspace.getLeavesOfType(type)) + .flat(1); + openLeaves.forEach((leaf) => leaf.detach()); // Empty trailDiv