Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/ui/PodcastView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import type { WorkspaceLeaf } from "obsidian";
import type { IPodNotes } from "../../types/IPodNotes";
import { VIEW_TYPE } from "../../constants";
import PodcastView from "./PodcastView.svelte";
import { mount, unmount } from "svelte";

export class MainView extends ItemView {
constructor(leaf: WorkspaceLeaf, private plugin: IPodNotes) {
super(leaf);
}

private podcastView: PodcastView | null = null;
private podcastView: Record<string, unknown> | null = null;

override getViewType(): string {
return VIEW_TYPE;
Expand All @@ -24,13 +25,16 @@ export class MainView extends ItemView {
}

protected override async onOpen(): Promise<void> {
this.podcastView = new PodcastView({
this.podcastView = mount(PodcastView, {
target: this.contentEl,
});
}

protected override async onClose(): Promise<void> {
this.podcastView?.$destroy();
if (this.podcastView) {
await unmount(this.podcastView);
this.podcastView = null;
}

this.contentEl.empty();
}
Expand Down
20 changes: 14 additions & 6 deletions src/ui/settings/PodNotesSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import type PodNotes from "../../main";
import PodcastQueryGrid from "./PodcastQueryGrid.svelte";
import PlaylistManager from "./PlaylistManager.svelte";
import { mount, unmount } from "svelte";
import {
DownloadPathTemplateEngine,
FilePathTemplateEngine,
Expand All @@ -23,8 +24,8 @@ import { clearFeedCache } from "src/services/FeedCacheService";
export class PodNotesSettingsTab extends PluginSettingTab {
plugin: PodNotes;

private podcastQueryGrid!: PodcastQueryGrid;
private playlistManager!: PlaylistManager;
private podcastQueryGrid: Record<string, unknown> | null = null;
private playlistManager: Record<string, unknown> | null = null;

private settingsTab: PodNotesSettingsTab;

Expand All @@ -51,7 +52,7 @@ export class PodNotesSettingsTab extends PluginSettingTab {
.setDesc("Search for podcasts by name or custom feed URL.");

const queryGridContainer = settingsContainer.createDiv();
this.podcastQueryGrid = new PodcastQueryGrid({
this.podcastQueryGrid = mount(PodcastQueryGrid, {
target: queryGridContainer,
});

Expand All @@ -61,7 +62,7 @@ export class PodNotesSettingsTab extends PluginSettingTab {
.setDesc("Add playlists to gather podcast episodes.");

const playlistManagerContainer = settingsContainer.createDiv();
this.playlistManager = new PlaylistManager({
this.playlistManager = mount(PlaylistManager, {
target: playlistManagerContainer,
});

Expand All @@ -76,8 +77,15 @@ export class PodNotesSettingsTab extends PluginSettingTab {
}

override hide(): void {
this.podcastQueryGrid?.$destroy();
this.playlistManager?.$destroy();
if (this.podcastQueryGrid) {
void unmount(this.podcastQueryGrid);
this.podcastQueryGrid = null;
}

if (this.playlistManager) {
void unmount(this.playlistManager);
this.playlistManager = null;
}
}

private addDefaultPlaybackRateSetting(container: HTMLElement): void {
Expand Down