feat: basic file drag and drop

This commit is contained in:
2025-09-20 22:25:01 +00:00
parent daae016cf3
commit d6b693b54b
7 changed files with 177 additions and 28 deletions

View File

@@ -34,3 +34,28 @@ export async function renameFile(
await ctx.db.patch(itemId, { name: newName })
}
export async function moveFiles(
ctx: AuthenticatedMutationCtx,
{
targetDirectoryId,
items,
}: {
targetDirectoryId: Id<"directories">
items: Id<"files">[]
},
) {
const targetDirectory = await ctx.db.get(targetDirectoryId)
if (!targetDirectory) {
throw Err.create(
Err.Code.DirectoryNotFound,
"Target directory not found",
)
}
await Promise.all(
items.map((itemId) =>
ctx.db.patch(itemId, { directoryId: targetDirectoryId }),
),
)
return { items, targetDirectory }
}