enh: drag and drop folders

This commit is contained in:
Timothy J. Baek
2024-10-16 23:06:53 -07:00
parent d5bf32f240
commit 36a541d6b0
5 changed files with 104 additions and 9 deletions
+22 -2
View File
@@ -43,7 +43,7 @@
import Folder from '../common/Folder.svelte';
import Plus from '../icons/Plus.svelte';
import Tooltip from '../common/Tooltip.svelte';
import { createNewFolder, getFolders } from '$lib/apis/folders';
import { createNewFolder, getFolders, updateFolderParentIdById } from '$lib/apis/folders';
import Folders from './Sidebar/Folders.svelte';
const BREAKPOINT = 768;
@@ -656,7 +656,12 @@
<div class=" flex-1 flex flex-col overflow-y-auto scrollbar-hidden">
{#if !search && folders}
<Folders {folders} />
<Folders
{folders}
on:update={async (e) => {
await initFolders();
}}
/>
{/if}
<Folder
@@ -677,6 +682,21 @@
initChatList();
}
}
} else if (type === 'folder') {
if (folders[id].parent_id === null) {
return;
}
const res = await updateFolderParentIdById(localStorage.token, id, null).catch(
(error) => {
toast.error(error);
return null;
}
);
if (res) {
await initFolders();
}
}
}}
>