Fix Khoj Obsidian plugin build

This commit is contained in:
Debanjum Singh Solanky 2024-07-07 18:18:00 +05:30
parent 510d9b3a29
commit 54132efd67
2 changed files with 8 additions and 7 deletions

View file

@ -18,6 +18,7 @@ do
# Bump Obsidian plugin to current version # Bump Obsidian plugin to current version
cd $project_root/src/interface/obsidian cd $project_root/src/interface/obsidian
yarn build # verify build before bumping version
yarn version --$version_type --no-git-tag-version yarn version --$version_type --no-git-tag-version
# append current version, min Obsidian app version from manifest to versions json # append current version, min Obsidian app version from manifest to versions json
cp $project_root/versions.json . cp $project_root/versions.json .

View file

@ -116,7 +116,7 @@ export class KhojChatView extends KhojPaneView {
title: "Show Conversations (^O)", title: "Show Conversations (^O)",
}, },
}) })
chatSessions.addEventListener('click', async (_) => { await this.toggleChatSessions(chatBodyEl) }); chatSessions.addEventListener('click', async (_) => { await this.toggleChatSessions() });
setIcon(chatSessions, "history"); setIcon(chatSessions, "history");
let chatInput = inputRow.createEl("textarea", { let chatInput = inputRow.createEl("textarea", {
@ -607,16 +607,16 @@ export class KhojChatView extends KhojPaneView {
return `${time_string}, ${date_string}`; return `${time_string}, ${date_string}`;
} }
createNewConversation(chatBodyEl: HTMLElement|undefined = undefined) { createNewConversation() {
chatBodyEl = chatBodyEl ?? this.contentEl.getElementsByClassName("khoj-chat-body")[0] as HTMLElement; let chatBodyEl = this.contentEl.getElementsByClassName("khoj-chat-body")[0] as HTMLElement;
chatBodyEl.innerHTML = ""; chatBodyEl.innerHTML = "";
chatBodyEl.dataset.conversationId = ""; chatBodyEl.dataset.conversationId = "";
chatBodyEl.dataset.conversationTitle = ""; chatBodyEl.dataset.conversationTitle = "";
this.renderMessage(chatBodyEl, "Hey 👋🏾, what's up?", "khoj"); this.renderMessage(chatBodyEl, "Hey 👋🏾, what's up?", "khoj");
} }
async toggleChatSessions(chatBodyEl: HTMLElement|undefined = undefined, forceShow: boolean = false): Promise<boolean> { async toggleChatSessions(forceShow: boolean = false): Promise<boolean> {
chatBodyEl = chatBodyEl ?? this.contentEl.getElementsByClassName("khoj-chat-body")[0] as HTMLElement; let chatBodyEl = this.contentEl.getElementsByClassName("khoj-chat-body")[0] as HTMLElement;
if (!forceShow && this.contentEl.getElementsByClassName("side-panel")?.length > 0) { if (!forceShow && this.contentEl.getElementsByClassName("side-panel")?.length > 0) {
chatBodyEl.innerHTML = ""; chatBodyEl.innerHTML = "";
return this.getChatHistory(chatBodyEl); return this.getChatHistory(chatBodyEl);
@ -630,7 +630,7 @@ export class KhojChatView extends KhojPaneView {
const newConversationButtonEl = newConversationEl.createEl("button"); const newConversationButtonEl = newConversationEl.createEl("button");
newConversationButtonEl.classList.add("new-conversation-button"); newConversationButtonEl.classList.add("new-conversation-button");
newConversationButtonEl.classList.add("side-panel-button"); newConversationButtonEl.classList.add("side-panel-button");
newConversationButtonEl.addEventListener('click', (_) => this.createNewConversation(chatBodyEl)); newConversationButtonEl.addEventListener('click', (_) => this.createNewConversation());
setIcon(newConversationButtonEl, "plus"); setIcon(newConversationButtonEl, "plus");
newConversationButtonEl.innerHTML += "New"; newConversationButtonEl.innerHTML += "New";
newConversationButtonEl.title = "New Conversation (^N)"; newConversationButtonEl.title = "New Conversation (^N)";
@ -793,7 +793,7 @@ export class KhojChatView extends KhojPaneView {
chatBodyEl.innerHTML = ""; chatBodyEl.innerHTML = "";
chatBodyEl.dataset.conversationId = ""; chatBodyEl.dataset.conversationId = "";
chatBodyEl.dataset.conversationTitle = ""; chatBodyEl.dataset.conversationTitle = "";
this.toggleChatSessions(chatBodyEl, true); this.toggleChatSessions(true);
}) })
.catch(err => { .catch(err => {
return; return;