diff --git a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte index 0523de415e..d2259d2578 100644 --- a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte +++ b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte @@ -176,24 +176,26 @@ }); } - // Move the chat - const res = await updateChatFolderIdById( - localStorage.token, - chat.id, - folderId - ).catch((error) => { - toast.error(`${error}`); - return null; - }); + if (chat) { + // Move the chat + const res = await updateChatFolderIdById( + localStorage.token, + chat.id, + folderId + ).catch((error) => { + toast.error(`${error}`); + return null; + }); - onItemMove({ - originFolderId: chat.folder_id, - targetFolderId: folderId, - e - }); + onItemMove({ + originFolderId: chat.folder_id, + targetFolderId: folderId, + e + }); - if (res) { - dispatch('update'); + if (res) { + dispatch('update'); + } } } } catch (error) {