mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-04 06:31:35 +08:00
create get/set for private funcs
This commit is contained in:
parent
997edd8de8
commit
229a29d1cb
@ -99,6 +99,39 @@ export default class LlmChatPanel extends BasicWidget {
|
||||
private onGetData: (() => Promise<any>) | null = null;
|
||||
private messages: Array<{role: string; content: string; timestamp?: Date}> = [];
|
||||
|
||||
// Public getters and setters for private properties
|
||||
public getCurrentNoteId(): string | null {
|
||||
return this.currentNoteId;
|
||||
}
|
||||
|
||||
public setCurrentNoteId(noteId: string | null): void {
|
||||
this.currentNoteId = noteId;
|
||||
}
|
||||
|
||||
public getMessages(): Array<{role: string; content: string; timestamp?: Date}> {
|
||||
return this.messages;
|
||||
}
|
||||
|
||||
public setMessages(messages: Array<{role: string; content: string; timestamp?: Date}>): void {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public getSessionId(): string | null {
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
public setSessionId(sessionId: string | null): void {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public getNoteContextChatMessages(): HTMLElement {
|
||||
return this.noteContextChatMessages;
|
||||
}
|
||||
|
||||
public clearNoteContextChatMessages(): void {
|
||||
this.noteContextChatMessages.innerHTML = '';
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
|
||||
|
@ -44,7 +44,7 @@ export default class AiChatTypeWidget extends TypeWidget {
|
||||
|
||||
// Force refresh the chat panel with the new note
|
||||
if (note) {
|
||||
this.llmChatPanel.currentNoteId = note.noteId;
|
||||
this.llmChatPanel.setCurrentNoteId(note.noteId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +91,8 @@ export default class AiChatTypeWidget extends TypeWidget {
|
||||
this.initPromise = (async () => {
|
||||
try {
|
||||
// Reset the UI before refreshing
|
||||
this.llmChatPanel.noteContextChatMessages.innerHTML = '';
|
||||
this.llmChatPanel.messages = [];
|
||||
this.llmChatPanel.clearNoteContextChatMessages();
|
||||
this.llmChatPanel.setMessages([]);
|
||||
|
||||
// This will load saved data via the getData callback
|
||||
await this.llmChatPanel.refresh();
|
||||
@ -125,12 +125,12 @@ export default class AiChatTypeWidget extends TypeWidget {
|
||||
|
||||
if (this.note) {
|
||||
// Update the chat panel with the new note ID before refreshing
|
||||
this.llmChatPanel.currentNoteId = this.note.noteId;
|
||||
this.llmChatPanel.setCurrentNoteId(this.note.noteId);
|
||||
|
||||
// Reset the chat panel UI
|
||||
this.llmChatPanel.noteContextChatMessages.innerHTML = '';
|
||||
this.llmChatPanel.messages = [];
|
||||
this.llmChatPanel.sessionId = null;
|
||||
this.llmChatPanel.clearNoteContextChatMessages();
|
||||
this.llmChatPanel.setMessages([]);
|
||||
this.llmChatPanel.setSessionId(null);
|
||||
}
|
||||
|
||||
// Call the parent method to refresh
|
||||
@ -151,14 +151,14 @@ export default class AiChatTypeWidget extends TypeWidget {
|
||||
|
||||
// Make sure the chat panel has the current note ID
|
||||
if (this.note) {
|
||||
this.llmChatPanel.currentNoteId = this.note.noteId;
|
||||
this.llmChatPanel.setCurrentNoteId(this.note.noteId);
|
||||
}
|
||||
|
||||
this.initPromise = (async () => {
|
||||
try {
|
||||
// Reset the UI before refreshing
|
||||
this.llmChatPanel.noteContextChatMessages.innerHTML = '';
|
||||
this.llmChatPanel.messages = [];
|
||||
this.llmChatPanel.clearNoteContextChatMessages();
|
||||
this.llmChatPanel.setMessages([]);
|
||||
|
||||
await this.llmChatPanel.refresh();
|
||||
this.isInitialized = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user