andy-stack_vaultkeeper-ai/Modals/HelpModal.ts
Andrew Beal 37db1a8908 refactor: improve type safety and add Zod validation for function arguments
- Change function arguments type from `Record<string, object>` to `Record<string, unknown>`
- Add Zod schemas for all AI function arguments validation
- Improve TypeScript types across modals and services
- Add ESLint disable comments for intentional exceptions
- Fix async/await handling in modal and view lifecycle methods
- Update dependencies (@typescript-eslint 8.46.4, rollup 4.53.2, zod 4.1.12)
2025-11-10 19:41:17 +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): void {
this.initialTopic = initialTopic;
super.open();
}
onClose() {
if (this.component) {
void unmount(this.component);
this.component = null;
}
const { contentEl } = this;
contentEl.empty();
}
}