mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
d3547f0f54
commit
1c83f48c45
1 changed files with 47 additions and 40 deletions
|
|
@ -114,59 +114,66 @@
|
||||||
} else {
|
} else {
|
||||||
// Handle the drag-and-drop data for folders or chats (same as before)
|
// Handle the drag-and-drop data for folders or chats (same as before)
|
||||||
const dataTransfer = e.dataTransfer.getData('text/plain');
|
const dataTransfer = e.dataTransfer.getData('text/plain');
|
||||||
const data = JSON.parse(dataTransfer);
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
const { type, id, item } = data;
|
try {
|
||||||
|
const data = JSON.parse(dataTransfer);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (type === 'folder') {
|
const { type, id, item } = data;
|
||||||
open = true;
|
|
||||||
if (id === folderId) {
|
if (type === 'folder') {
|
||||||
return;
|
open = true;
|
||||||
}
|
if (id === folderId) {
|
||||||
// Move the folder
|
return;
|
||||||
const res = await updateFolderParentIdById(localStorage.token, id, folderId).catch(
|
|
||||||
(error) => {
|
|
||||||
toast.error(`${error}`);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
);
|
// Move the folder
|
||||||
|
const res = await updateFolderParentIdById(localStorage.token, id, folderId).catch(
|
||||||
|
(error) => {
|
||||||
|
toast.error(`${error}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
dispatch('update');
|
dispatch('update');
|
||||||
}
|
}
|
||||||
} else if (type === 'chat') {
|
} else if (type === 'chat') {
|
||||||
open = true;
|
open = true;
|
||||||
|
|
||||||
let chat = await getChatById(localStorage.token, id).catch((error) => {
|
let chat = await getChatById(localStorage.token, id).catch((error) => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
if (!chat && item) {
|
if (!chat && item) {
|
||||||
chat = await importChat(
|
chat = await importChat(
|
||||||
|
localStorage.token,
|
||||||
|
item.chat,
|
||||||
|
item?.meta ?? {},
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
item?.created_at ?? null,
|
||||||
|
item?.updated_at ?? null
|
||||||
|
).catch((error) => {
|
||||||
|
toast.error(`${error}`);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move the chat
|
||||||
|
const res = await updateChatFolderIdById(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
item.chat,
|
chat.id,
|
||||||
item?.meta ?? {},
|
folderId
|
||||||
false,
|
|
||||||
null,
|
|
||||||
item?.created_at ?? null,
|
|
||||||
item?.updated_at ?? null
|
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Move the chat
|
if (res) {
|
||||||
const res = await updateChatFolderIdById(localStorage.token, chat.id, folderId).catch(
|
dispatch('update');
|
||||||
(error) => {
|
|
||||||
toast.error(`${error}`);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
dispatch('update');
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Error parsing dataTransfer:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue