andy-stack_vaultkeeper-ai/Modals/HelpModal.ts
Andrew Beal 167a2b13a5 refactor: standardize error handling with Exception helper and improve return types
Add Exception helper class for consistent error handling and logging. Replace throw statements and console.error calls with Exception methods. Update service methods to return Error | T instead of mixed success/failure objects. Improve type safety in Claude.extractContents with explicit return type.

Add WikiLinks helper to VaultCacheService for managing wiki link references.

Update unit tests.
2025-11-17 19:02:15 +00:00

48 lines
No EOL
1.3 KiB
TypeScript

import type VaultkeeperAIPlugin from "main";
import { Modal } from "obsidian";
import { Resolve } from "Services/DependencyService";
import { Services } from "Services/Services";
import HelpModalSvelte from './HelpModalSvelte.svelte';
import { mount, unmount } from 'svelte';
import { Selector } from 'Enums/Selector';
export class HelpModal extends Modal {
private component: ReturnType<typeof mount> | null = null;
private initialTopic?: number;
public constructor() {
const plugin = Resolve<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
super(plugin.app);
}
onOpen() {
const { contentEl, modalEl, containerEl } = this;
containerEl.addClass(Selector.HelpModal);
modalEl.addClass(Selector.HelpModal);
this.component = mount(HelpModalSvelte, {
target: contentEl,
props: {
onClose: () => this.close(),
initialTopic: this.initialTopic
}
});
}
public open(initialTopic?: number) {
this.initialTopic = initialTopic;
super.open();
}
onClose() {
if (this.component) {
void unmount(this.component);
this.component = null;
}
const { contentEl } = this;
contentEl.empty();
}
}