Skip to content

Commit

Permalink
fix: enable plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Nov 7, 2024
1 parent 3a4dc7b commit d9b581d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default class Handlers {
if (parameters["enable-plugin"]) {
const pluginId = parameters["enable-plugin"];

if (this.app.plugins.getPlugin(pluginId)) {
if (
pluginId in this.app.plugins.manifests &&
!this.app.plugins.getPlugin(pluginId)
) {
this.app.plugins.enablePluginAndSave(pluginId);
new Notice(`Enabled ${pluginId}`);
} else if (this.app.internalPlugins.plugins[pluginId]) {
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ declare module "obsidian" {
};
enablePluginAndSave(plugin: string): void;
disablePluginAndSave(plugin: string): void;
/** Returns the plugin instance if enabled and loaded */
getPlugin(plugin: string): Plugin | null;
manifests: Record<string, PluginManifest>;
checkForUpdates(): Promise<void>;
updates: {
[key: string]: {};
Expand Down

0 comments on commit d9b581d

Please sign in to comment.