mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
fix: add null checks to chat iterators in ArchivedChats and FolderPlaceholder (#19898)
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import { getContext, onMount } from 'svelte';
|
import { getContext, onMount } from 'svelte';
|
||||||
const i18n = getContext('i18n');
|
import type { Writable } from 'svelte/store';
|
||||||
|
|
||||||
|
const i18n: Writable<any> = getContext('i18n');
|
||||||
|
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
@@ -9,13 +11,13 @@
|
|||||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||||
import { getChatListByFolderId } from '$lib/apis/chats';
|
import { getChatListByFolderId } from '$lib/apis/chats';
|
||||||
|
|
||||||
export let folder = null;
|
export let folder: any = null;
|
||||||
|
|
||||||
let selectedTab = 'chats';
|
let selectedTab = 'chats';
|
||||||
|
|
||||||
let page = 1;
|
let page = 1;
|
||||||
|
|
||||||
let chats = null;
|
let chats: any[] | null = null;
|
||||||
let chatListLoading = false;
|
let chatListLoading = false;
|
||||||
let allChatsLoaded = false;
|
let allChatsLoaded = false;
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
|
|
||||||
page += 1;
|
page += 1;
|
||||||
|
|
||||||
let newChatList = [];
|
let newChatList: any[] = [];
|
||||||
|
|
||||||
newChatList = await getChatListByFolderId(localStorage.token, folder.id, page).catch(
|
newChatList = await getChatListByFolderId(localStorage.token, folder.id, page).catch(
|
||||||
(error) => {
|
(error) => {
|
||||||
@@ -35,7 +37,7 @@
|
|||||||
|
|
||||||
// once the bottom of the list has been reached (no results) there is no need to continue querying
|
// once the bottom of the list has been reached (no results) there is no need to continue querying
|
||||||
allChatsLoaded = newChatList.length === 0;
|
allChatsLoaded = newChatList.length === 0;
|
||||||
chats = [...chats, ...newChatList];
|
chats = [...(chats || []), ...(newChatList || [])];
|
||||||
|
|
||||||
chatListLoading = false;
|
chatListLoading = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
// @ts-ignore
|
||||||
import fileSaver from 'file-saver';
|
import fileSaver from 'file-saver';
|
||||||
|
import type { Writable } from 'svelte/store';
|
||||||
const { saveAs } = fileSaver;
|
const { saveAs } = fileSaver;
|
||||||
|
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
@@ -15,13 +17,13 @@
|
|||||||
import UnarchiveAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
import UnarchiveAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||||
import Spinner from '../common/Spinner.svelte';
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n: Writable<any> = getContext('i18n');
|
||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
export let onUpdate = () => {};
|
export let onUpdate = () => {};
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let chatList = null;
|
let chatList: any[] | null = null;
|
||||||
let page = 1;
|
let page = 1;
|
||||||
|
|
||||||
let query = '';
|
let query = '';
|
||||||
@@ -30,13 +32,13 @@
|
|||||||
|
|
||||||
let allChatsLoaded = false;
|
let allChatsLoaded = false;
|
||||||
let chatListLoading = false;
|
let chatListLoading = false;
|
||||||
let searchDebounceTimeout;
|
let searchDebounceTimeout: any;
|
||||||
|
|
||||||
let showUnarchiveAllConfirmDialog = false;
|
let showUnarchiveAllConfirmDialog = false;
|
||||||
|
|
||||||
let filter = {};
|
let filter: any = {};
|
||||||
$: filter = {
|
$: filter = {
|
||||||
...(query ? { query: query } : {}),
|
...(query ? { query } : {}),
|
||||||
...(orderBy ? { order_by: orderBy } : {}),
|
...(orderBy ? { order_by: orderBy } : {}),
|
||||||
...(direction ? { direction } : {})
|
...(direction ? { direction } : {})
|
||||||
};
|
};
|
||||||
@@ -88,7 +90,7 @@
|
|||||||
allChatsLoaded = newChatList.length === 0;
|
allChatsLoaded = newChatList.length === 0;
|
||||||
|
|
||||||
if (newChatList.length > 0) {
|
if (newChatList.length > 0) {
|
||||||
chatList = [...chatList, ...newChatList];
|
chatList = [...(chatList || []), ...newChatList];
|
||||||
}
|
}
|
||||||
|
|
||||||
chatListLoading = false;
|
chatListLoading = false;
|
||||||
@@ -102,7 +104,7 @@
|
|||||||
saveAs(blob, `${$i18n.t('archived-chat-export')}-${Date.now()}.json`);
|
saveAs(blob, `${$i18n.t('archived-chat-export')}-${Date.now()}.json`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const unarchiveHandler = async (chatId) => {
|
const unarchiveHandler = async (chatId: string) => {
|
||||||
const res = await archiveChatById(localStorage.token, chatId).catch((error) => {
|
const res = await archiveChatById(localStorage.token, chatId).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user