Toggle chat session view on clicking the Obsidian chat sessions button

This commit is contained in:
Debanjum Singh Solanky
2024-05-30 13:47:26 +05:30
parent 275d4877a6
commit 2d010db83f
2 changed files with 7 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ export class KhojChatView extends KhojPaneView {
class: "khoj-input-row-button clickable-icon", class: "khoj-input-row-button clickable-icon",
}, },
}) })
chatSessions.addEventListener('click', async (_) => { await this.showChatSessions(chatBodyEl) }); chatSessions.addEventListener('click', async (_) => { await this.toggleChatSessions(chatBodyEl) });
setIcon(chatSessions, "history"); setIcon(chatSessions, "history");
let chatInput = inputRow.createEl("textarea", { let chatInput = inputRow.createEl("textarea", {
@@ -468,7 +468,11 @@ export class KhojChatView extends KhojPaneView {
this.renderMessage(chatBodyEl, "Hey 👋🏾, what's up?", "khoj"); this.renderMessage(chatBodyEl, "Hey 👋🏾, what's up?", "khoj");
} }
async showChatSessions(chatBodyEl: HTMLElement): Promise<boolean> { async toggleChatSessions(chatBodyEl: HTMLElement): Promise<boolean> {
if (this.contentEl.getElementsByClassName("side-panel")?.length > 0) {
chatBodyEl.innerHTML = "";
return this.getChatHistory(chatBodyEl);
}
chatBodyEl.innerHTML = ""; chatBodyEl.innerHTML = "";
const sidePanelEl = this.contentEl.createDiv("side-panel"); const sidePanelEl = this.contentEl.createDiv("side-panel");
const newConversationEl = sidePanelEl.createDiv("new-conversation"); const newConversationEl = sidePanelEl.createDiv("new-conversation");

View File

@@ -24,6 +24,7 @@ If your plugin does not need CSS, delete this file.
.khoj-chat { .khoj-chat {
display: grid; display: grid;
grid-template-rows: auto 1fr auto;
background: var(--background-primary); background: var(--background-primary);
color: var(--text-normal); color: var(--text-normal);
text-align: center; text-align: center;