refac/enh: folder optimization

This commit is contained in:
Timothy Jaeryang Baek
2025-09-26 20:48:17 -05:00
parent 54beeeaf72
commit c80bb31968
9 changed files with 153 additions and 32 deletions
+39
View File
@@ -327,6 +327,45 @@ export const getChatsByFolderId = async (token: string, folderId: string) => {
return res;
};
export const getChatListByFolderId = async (token: string, folderId: string, page: number = 1) => {
let error = null;
const searchParams = new URLSearchParams();
if (page !== null) {
searchParams.append('page', `${page}`);
}
const res = await fetch(
`${WEBUI_API_BASE_URL}/chats/folder/${folderId}/list?${searchParams.toString()}`,
{
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(token && { authorization: `Bearer ${token}` })
}
}
)
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err;
console.error(err);
return null;
});
if (error) {
throw error;
}
return res;
};
export const getAllArchivedChats = async (token: string) => {
let error = null;