mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
refac
Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
This commit is contained in:
parent
80f3c97668
commit
6176dba3c9
3 changed files with 11 additions and 6 deletions
|
|
@ -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<string, any>;
|
||||
};
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<Model[]> = writable([]);
|
||||
|
||||
export const prompts: Writable<null | Prompt[]> = writable(null);
|
||||
|
|
|
|||
Loading…
Reference in a new issue