Skip to content

Commit 13557db

Browse files
committed
refactor: Obsidian object is no longer global, use this.app
1 parent 10b02fa commit 13557db

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/main.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ export default class PodNotes extends Plugin implements IPodNotes {
108108
icon: "podcast" as IconType,
109109
checkCallback(checking: boolean) {
110110
if (checking) {
111-
return !app.workspace.getLeavesOfType(VIEW_TYPE).length;
111+
return !this.app.workspace.getLeavesOfType(VIEW_TYPE).length;
112112
}
113113

114-
app.workspace.getRightLeaf(false).setViewState({
114+
this.app.workspace.getRightLeaf(false).setViewState({
115115
type: VIEW_TYPE,
116116
});
117117
},
@@ -285,9 +285,13 @@ export default class PodNotes extends Plugin implements IPodNotes {
285285
return;
286286
}
287287

288-
this.app.workspace.getRightLeaf(false).setViewState({
289-
type: VIEW_TYPE,
290-
});
288+
const leaf = this.app.workspace.getRightLeaf(false);
289+
290+
if (leaf) {
291+
leaf.setViewState({
292+
type: VIEW_TYPE,
293+
});
294+
}
291295
}
292296

293297
onunload() {

src/parser/feedParser.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { PodcastFeed } from "src/types/PodcastFeed";
1+
import type { PodcastFeed } from "src/types/PodcastFeed";
22
import { requestUrl } from "obsidian";
3-
import { Episode } from "src/types/Episode";
3+
import type { Episode } from "src/types/Episode";
44

55
export default class FeedParser {
66
private feed: PodcastFeed | undefined;
@@ -83,9 +83,7 @@ export default class FeedParser {
8383
return !!ep;
8484
}
8585

86-
return Array.from(items)
87-
.map(this.parseItem.bind(this))
88-
.filter(isEpisode);
86+
return Array.from(items).map(this.parseItem.bind(this)).filter(isEpisode);
8987
}
9088

9189
protected parseItem(item: Element): Episode | null {
@@ -96,7 +94,7 @@ export default class FeedParser {
9694
const contentEl = item.querySelector("*|encoded");
9795
const pubDateEl = item.querySelector("pubDate");
9896
const itunesImageEl = item.querySelector("image");
99-
const itunesTitleEl = item.getElementsByTagName('itunes:title')[0];
97+
const itunesTitleEl = item.getElementsByTagName("itunes:title")[0];
10098

10199
if (!titleEl || !streamUrlEl || !pubDateEl) {
102100
return null;
@@ -122,7 +120,7 @@ export default class FeedParser {
122120
artworkUrl,
123121
episodeDate: pubDate,
124122
feedUrl: this.feed?.url || "",
125-
itunesTitle: itunesTitle || ""
123+
itunesTitle: itunesTitle || "",
126124
};
127125
}
128126

0 commit comments

Comments
 (0)