Skip to content

Commit

Permalink
extend app type so I can remove //@ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Nov 8, 2022
1 parent 31a38be commit 394b218
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 394b218

Please sign in to comment.