refac/pref: chat import optimization

Co-Authored-By: G30 <50341825+silentoplayz@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2025-11-21 03:49:49 -05:00
co-authored by G30
parent 3ef7367f01
commit a51579a84b
6 changed files with 116 additions and 119 deletions
+31 -28
View File
@@ -38,7 +38,7 @@
toggleChatPinnedStatusById,
getChatById,
updateChatFolderIdById,
importChat
importChats
} from '$lib/apis/chats';
import { createNewFolder, getFolders, updateFolderParentIdById } from '$lib/apis/folders';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
@@ -227,15 +227,16 @@
for (const item of items) {
console.log(item);
if (item.chat) {
await importChat(
localStorage.token,
item.chat,
item?.meta ?? {},
pinned,
folderId,
item?.created_at ?? null,
item?.updated_at ?? null
);
await importChats(localStorage.token, [
{
chat: item.chat,
meta: item?.meta ?? {},
pinned: pinned,
folder_id: folderId,
created_at: item?.created_at ?? null,
updated_at: item?.updated_at ?? null
}
]);
}
}
@@ -999,15 +1000,16 @@
return null;
});
if (!chat && item) {
chat = await importChat(
localStorage.token,
item.chat,
item?.meta ?? {},
false,
null,
item?.created_at ?? null,
item?.updated_at ?? null
);
chat = await importChats(localStorage.token, [
{
chat: item.chat,
meta: item?.meta ?? {},
pinned: false,
folder_id: null,
created_at: item?.created_at ?? null,
updated_at: item?.updated_at ?? null
}
]);
}
if (chat) {
@@ -1064,15 +1066,16 @@
return null;
});
if (!chat && item) {
chat = await importChat(
localStorage.token,
item.chat,
item?.meta ?? {},
false,
null,
item?.created_at ?? null,
item?.updated_at ?? null
);
chat = await importChats(localStorage.token, [
{
chat: item.chat,
meta: item?.meta ?? {},
pinned: false,
folder_id: null,
created_at: item?.created_at ?? null,
updated_at: item?.updated_at ?? null
}
]);
}
if (chat) {
@@ -24,8 +24,8 @@
getChatById,
getChatsByFolderId,
getChatListByFolderId,
importChat,
updateChatFolderIdById
updateChatFolderIdById,
importChats
} from '$lib/apis/chats';
import ChevronDown from '../../icons/ChevronDown.svelte';
@@ -152,15 +152,16 @@
return null;
});
if (!chat && item) {
chat = await importChat(
localStorage.token,
item.chat,
item?.meta ?? {},
false,
null,
item?.created_at ?? null,
item?.updated_at ?? null
).catch((error) => {
chat = await importChats(localStorage.token, [
{
chat: item.chat,
meta: item?.meta ?? {},
pinned: false,
folder_id: null,
created_at: item?.created_at ?? null,
updated_at: item?.updated_at ?? null
}
]).catch((error) => {
toast.error(`${error}`);
return null;
});