diff --git a/src/lib/apis/folders/index.ts b/src/lib/apis/folders/index.ts index 21ec426b05..243cdb1dbf 100644 --- a/src/lib/apis/folders/index.ts +++ b/src/lib/apis/folders/index.ts @@ -92,7 +92,12 @@ export const getFolderById = async (token: string, id: string) => { return res; }; -export const updateFolderNameById = async (token: string, id: string, name: string) => { +type FolderForm = { + name: string; + data?: Record; +}; + +export const updateFolderById = async (token: string, id: string, folderForm: FolderForm) => { let error = null; const res = await fetch(`${WEBUI_API_BASE_URL}/folders/${id}/update`, { @@ -102,9 +107,7 @@ export const updateFolderNameById = async (token: string, id: string, name: stri 'Content-Type': 'application/json', authorization: `Bearer ${token}` }, - body: JSON.stringify({ - name: name - }) + body: JSON.stringify(folderForm) }) .then(async (res) => { if (!res.ok) throw await res.json(); diff --git a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte index 4e0d2ba465..a30a14a4b4 100644 --- a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte +++ b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte @@ -18,7 +18,7 @@ import { deleteFolderById, updateFolderIsExpandedById, - updateFolderNameById, + updateFolderById, updateFolderParentIdById } from '$lib/apis/folders'; import { toast } from 'svelte-sonner'; @@ -278,7 +278,7 @@ name = name.trim(); folders[folderId].name = name; - const res = await updateFolderNameById(localStorage.token, folderId, name).catch((error) => { + const res = await updateFolderById(localStorage.token, folderId, { name }).catch((error) => { toast.error(`${error}`); folders[folderId].name = currentName; diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 87dba04be9..e813c5c834 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -51,6 +51,8 @@ export const chats = writable(null); export const pinnedChats = writable([]); export const tags = writable([]); +export const selectedFolder = writable(null); + export const models: Writable = writable([]); export const prompts: Writable = writable(null);