From b9c36eb3e84a11cdfa529738bcdf9a7ada921b1a Mon Sep 17 00:00:00 2001 From: Heesu Suh Date: Sat, 2 Nov 2024 23:00:19 +0900 Subject: [PATCH] hotfix: use openChatView instead of openNewChat because it's buggy --- src/main.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index a6ed392..f99fea1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,7 @@ export default class SmartCopilotPlugin extends Plugin { this.addCommand({ id: 'open-new-chat', name: 'Open chat', - callback: () => this.openNewChat(), + callback: () => this.openChatView(), }) this.addCommand({ @@ -158,6 +158,9 @@ export default class SmartCopilotPlugin extends Plugin { }) } + /** + * TODO: this is buggy, should fix first before using it + */ async openNewChat() { const view = this.app.workspace.getActiveViewOfType(MarkdownView) const editor = view?.editor @@ -175,6 +178,7 @@ export default class SmartCopilotPlugin extends Plugin { } else { const chatView = this.app.workspace.getLeavesOfType(CHAT_VIEW_TYPE)[0] .view as ChatView + // sometimes, "openNewChat" not exists in chatView. don't know why chatView.openNewChat(selectedBlock ?? undefined) } }