From 394b2183a83c35b1ce583bb42c9c18838a84e72e Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann <christian@bagerbach.com> Date: Tue, 8 Nov 2022 20:27:21 +0100 Subject: [PATCH] extend app type so I can remove //@ts-ignore --- src/global.d.ts | 33 +++++++++++++++++++++++++++++++++ src/main.ts | 4 +++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/global.d.ts diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..e3d40f5 --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,33 @@ +import { App } from "obsidian"; + +interface Manifest { + author: string; + authorUrl: string; + description: string; + dir: string; + id: string; + isDesktopOnly: boolean; + minAppVersion: string; + name: string; + version: string; +} + +// Not everything is implemented. +interface App2 extends App { + plugins: { + app: App; + enabledPlugins: Set<string>; + loadingPluginId: string; + manifests: Record<string, Manifest>; + plugins: Record<string, { + manifest: Manifest; + app: App, + }>; + requestSaveConfig: () => void; + updates: Record<string, any>; + enablePlugin: (id: string) => Promise<void>; + disablePlugin: (id: string) => Promise<void>; + }; +} + +export default App2; diff --git a/src/main.ts b/src/main.ts index 1402241..76bfa11 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,10 +40,12 @@ import DownloadedEpisodesController from "./store_controllers/DownloadedEpisodes import { TFile } from "obsidian"; import { createMediaUrlObjectFromFilePath } from "./utility/createUrlObjectFromFilePath"; import { LocalFilesController } from "./store_controllers/LocalFilesController"; +import PartialAppExtension from "./global"; export default class PodNotes extends Plugin implements IPodNotes { public api: IAPI; public settings: IPodNotesSettings; + public app: PartialAppExtension; private view: MainView; @@ -176,7 +178,7 @@ export default class PodNotes extends Plugin implements IPodNotes { name: "Reload PodNotes", callback: () => { const id = this.manifest.id; - //@ts-ignore + this.app.plugins .disablePlugin(id) .then(() => this.app.plugins.enablePlugin(id)); -- GitLab