Skip to content

Commit

Permalink
refactor: Obsidian object is no longer global, use this.app
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jul 18, 2024
1 parent 10b02fa commit 13557db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export default class PodNotes extends Plugin implements IPodNotes {
icon: "podcast" as IconType,
checkCallback(checking: boolean) {
if (checking) {
return !app.workspace.getLeavesOfType(VIEW_TYPE).length;
return !this.app.workspace.getLeavesOfType(VIEW_TYPE).length;
}

app.workspace.getRightLeaf(false).setViewState({
this.app.workspace.getRightLeaf(false).setViewState({
type: VIEW_TYPE,
});
},
Expand Down Expand Up @@ -285,9 +285,13 @@ export default class PodNotes extends Plugin implements IPodNotes {
return;
}

this.app.workspace.getRightLeaf(false).setViewState({
type: VIEW_TYPE,
});
const leaf = this.app.workspace.getRightLeaf(false);

if (leaf) {
leaf.setViewState({
type: VIEW_TYPE,
});
}
}

onunload() {
Expand Down
12 changes: 5 additions & 7 deletions src/parser/feedParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PodcastFeed } from "src/types/PodcastFeed";
import type { PodcastFeed } from "src/types/PodcastFeed";
import { requestUrl } from "obsidian";
import { Episode } from "src/types/Episode";
import type { Episode } from "src/types/Episode";

export default class FeedParser {
private feed: PodcastFeed | undefined;
Expand Down Expand Up @@ -83,9 +83,7 @@ export default class FeedParser {
return !!ep;
}

return Array.from(items)
.map(this.parseItem.bind(this))
.filter(isEpisode);
return Array.from(items).map(this.parseItem.bind(this)).filter(isEpisode);
}

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

if (!titleEl || !streamUrlEl || !pubDateEl) {
return null;
Expand All @@ -122,7 +120,7 @@ export default class FeedParser {
artworkUrl,
episodeDate: pubDate,
feedUrl: this.feed?.url || "",
itunesTitle: itunesTitle || ""
itunesTitle: itunesTitle || "",
};
}

Expand Down

0 comments on commit 13557db

Please sign in to comment.