fix: add null checks to chat iterators in ArchivedChats and FolderPlaceholder (#19898)

This commit is contained in:
G30
2025-12-11 20:34:39 -05:00
committed by GitHub
parent 8e661a4e73
commit 18e6cfb1fd
2 changed files with 17 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
<script>
<script lang="ts">
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';
@@ -9,13 +11,13 @@
import Spinner from '$lib/components/common/Spinner.svelte';
import { getChatListByFolderId } from '$lib/apis/chats';
export let folder = null;
export let folder: any = null;
let selectedTab = 'chats';
let page = 1;
let chats = null;
let chats: any[] | null = null;
let chatListLoading = false;
let allChatsLoaded = false;
@@ -24,7 +26,7 @@
page += 1;
let newChatList = [];
let newChatList: any[] = [];
newChatList = await getChatListByFolderId(localStorage.token, folder.id, page).catch(
(error) => {
@@ -35,7 +37,7 @@
// once the bottom of the list has been reached (no results) there is no need to continue querying
allChatsLoaded = newChatList.length === 0;
chats = [...chats, ...newChatList];
chats = [...(chats || []), ...(newChatList || [])];
chatListLoading = false;
};

View File

@@ -1,5 +1,7 @@
<script lang="ts">
// @ts-ignore
import fileSaver from 'file-saver';
import type { Writable } from 'svelte/store';
const { saveAs } = fileSaver;
import { toast } from 'svelte-sonner';
@@ -15,13 +17,13 @@
import UnarchiveAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
import Spinner from '../common/Spinner.svelte';
const i18n = getContext('i18n');
const i18n: Writable<any> = getContext('i18n');
export let show = false;
export let onUpdate = () => {};
let loading = false;
let chatList = null;
let chatList: any[] | null = null;
let page = 1;
let query = '';
@@ -30,13 +32,13 @@
let allChatsLoaded = false;
let chatListLoading = false;
let searchDebounceTimeout;
let searchDebounceTimeout: any;
let showUnarchiveAllConfirmDialog = false;
let filter = {};
let filter: any = {};
$: filter = {
...(query ? { query: query } : {}),
...(query ? { query } : {}),
...(orderBy ? { order_by: orderBy } : {}),
...(direction ? { direction } : {})
};
@@ -88,7 +90,7 @@
allChatsLoaded = newChatList.length === 0;
if (newChatList.length > 0) {
chatList = [...chatList, ...newChatList];
chatList = [...(chatList || []), ...newChatList];
}
chatListLoading = false;
@@ -102,7 +104,7 @@
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) => {
toast.error(`${error}`);
});