chore: use new mount syntax for Svelte 5

This commit is contained in:
DecafDev 2025-05-02 20:06:30 -06:00
parent 369dfad524
commit 09f6f1666a

View file

@ -1,18 +1,19 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import { VAULT_EXPLORER_VIEW } from "src/constants";
import VaultExplorerApp from "../svelte/app/index.svelte";
import VaultExplorerPlugin from "src/main";
import EventManager from "src/event/event-manager";
import { PluginEvent } from "src/event/types";
import VaultExplorerPlugin from "src/main";
import { mount, unmount } from "svelte";
import VaultExplorerApp from "../svelte/app/index.svelte";
export default class VaultExplorerView extends ItemView {
component: VaultExplorerApp | null;
svelteApp: ReturnType<typeof mount> | null;
plugin: VaultExplorerPlugin;
constructor(leaf: WorkspaceLeaf, plugin: VaultExplorerPlugin) {
super(leaf);
this.component = null;
this.svelteApp = null;
this.plugin = plugin;
this.navigation = true;
}
@ -43,12 +44,14 @@ export default class VaultExplorerView extends ItemView {
const containerEl = this.containerEl.children[1];
this.component = new VaultExplorerApp({
this.svelteApp = mount(VaultExplorerApp, {
target: containerEl
});
}
async onClose() {
this.component?.$destroy();
if (this.svelteApp) {
unmount(this.svelteApp);
}
}
}