andy-stack_vaultkeeper-ai/Views/MainView.ts
Andrew Beal a77c5b3339 refactor: replace sparkles icon with custom plugin icon throughout app
- Add AssetsService to manage plugin icon and banner assets
- Update sidebar, ribbon, and quick actions to use new icon
- Add plugin banner to help modal welcome section
- Update help text to reference "plugin icon" instead of "sparkles icon"
2026-05-31 19:45:05 +01:00

71 lines
No EOL
1.6 KiB
TypeScript

import { ItemView, WorkspaceLeaf } from 'obsidian';
import { mount, unmount } from 'svelte';
import ChatWindow from 'Components/ChatWindow.svelte';
import TopBar from 'Components/TopBar.svelte';
import { AssetsService } from 'Services/AssetsService';
import { Resolve } from 'Services/DependencyService';
import { Services } from 'Services/Services';
export const VIEW_TYPE_MAIN = 'vaultkeeper-ai-main-view';
interface ChatWindowComponent {
focusInput: () => void;
resetChatArea: () => void;
}
export class MainView extends ItemView {
private readonly assetsService: AssetsService;
constructor(leaf: WorkspaceLeaf) {
super(leaf);
this.assetsService = Resolve<AssetsService>(Services.AssetsService);
}
topBar: ReturnType<typeof TopBar> | undefined;
input: ChatWindowComponent | undefined;
public getViewType() {
return VIEW_TYPE_MAIN;
}
public getDisplayText() {
return "Vaultkeeper AI";
}
public getIcon(): string {
return this.assetsService.pluginIcon;
}
protected override onOpen(): Promise<void> {
const container = this.contentEl;
container.empty();
this.topBar = mount(TopBar, {
target: container,
props: {
leaf: this.leaf,
onNewConversation: () => {
this.input?.resetChatArea();
this.input?.focusInput();
}
}
});
this.input = mount(ChatWindow, {
target: container,
props: {}
}) as ChatWindowComponent;
return Promise.resolve();
}
public override async onClose(): Promise<void> {
if (this.topBar) {
await unmount(this.topBar);
}
if (this.input) {
await unmount(this.input);
}
}
}