Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/webapp/src/components/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class HistoryComponent extends LitElement {
async onChatClicked(sessionId: string) {
try {
this.isLoading = true;
const response = await fetch(`${this.options.apiUrl}/api/chats/${sessionId}/?userId=${this.userId}`);
const response = await fetch(`${this.getApiUrl()}/api/chats/${sessionId}/?userId=${this.userId}`);
const messages = await response.json();
const loadSessionEvent = new CustomEvent('loadSession', {
detail: { id: sessionId, messages },
Expand All @@ -92,7 +92,7 @@ export class HistoryComponent extends LitElement {
try {
this.chats = this.chats.filter((chat) => chat.id !== sessionId);

await fetch(`${this.options.apiUrl}/api/chats/${sessionId}?userId=${this.userId}`, {
await fetch(`${this.getApiUrl()}/api/chats/${sessionId}?userId=${this.userId}`, {
method: 'DELETE',
});
} catch (error) {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class HistoryComponent extends LitElement {
this.isLoading = true;
this.hasError = false;
try {
const response = await fetch(`${this.options.apiUrl}/api/chats?userId=${this.userId}`);
const response = await fetch(`${this.getApiUrl()}/api/chats?userId=${this.userId}`);
const chats = await response.json();
this.chats = chats;
this.isLoading = false;
Expand All @@ -155,6 +155,8 @@ export class HistoryComponent extends LitElement {
}
}

protected getApiUrl = () => this.options.apiUrl || import.meta.env.VITE_API_URL || '';

protected renderLoader = () =>
this.isLoading ? html`<slot name="loader"><div class="loader-animation"></div></slot>` : nothing;

Expand Down