mirror of
https://github.com/get-drexa/drive.git
synced 2025-11-30 21:41:39 +00:00
fix: broken dir path breadcrumb links
This commit is contained in:
@@ -6,14 +6,13 @@ import type {
|
||||
import * as Err from "./error"
|
||||
import {
|
||||
type DirectoryHandle,
|
||||
type FilePath,
|
||||
type DirectoryPath,
|
||||
type FileSystemItem,
|
||||
FileType,
|
||||
newDirectoryHandle,
|
||||
type ReverseFilePath,
|
||||
} from "./filesystem"
|
||||
|
||||
export type DirectoryInfo = Doc<"directories"> & { path: FilePath }
|
||||
export type DirectoryInfo = Doc<"directories"> & { path: DirectoryPath }
|
||||
|
||||
export async function fetchRoot(ctx: AuthenticatedQueryCtx) {
|
||||
return await ctx.db
|
||||
@@ -50,7 +49,7 @@ export async function fetch(
|
||||
)
|
||||
}
|
||||
|
||||
const path: ReverseFilePath = [
|
||||
const path: DirectoryPath = [
|
||||
{
|
||||
handle: newDirectoryHandle(directoryId),
|
||||
name: directory.name,
|
||||
@@ -70,7 +69,7 @@ export async function fetch(
|
||||
}
|
||||
}
|
||||
|
||||
return { ...directory, path: path.reverse() as FilePath }
|
||||
return { ...directory, path: path.reverse() as DirectoryPath }
|
||||
}
|
||||
|
||||
export async function fetchContent(
|
||||
|
||||
@@ -29,6 +29,10 @@ export type FilePathComponent = {
|
||||
name: string
|
||||
}
|
||||
export type PathComponent = FilePathComponent | DirectoryPathComponent
|
||||
export type DirectoryPath = [
|
||||
DirectoryPathComponent,
|
||||
...DirectoryPathComponent[],
|
||||
]
|
||||
export type FilePath = [...DirectoryPathComponent[], PathComponent]
|
||||
export type ReverseFilePath = [PathComponent, ...DirectoryPathComponent[]]
|
||||
|
||||
@@ -154,10 +158,8 @@ export async function restoreItems(
|
||||
{ handles }: { handles: FileSystemHandle[] },
|
||||
) {
|
||||
// Collect all items to restore (including nested items)
|
||||
const { fileHandles, directoryHandles } = await collectAllHandlesRecursively(
|
||||
ctx,
|
||||
{ handles },
|
||||
)
|
||||
const { fileHandles, directoryHandles } =
|
||||
await collectAllHandlesRecursively(ctx, { handles })
|
||||
|
||||
// Restore files and directories by unsetting deletedAt
|
||||
const [filesResult, directoriesResult] = await Promise.all([
|
||||
@@ -183,8 +185,10 @@ export async function deleteItemsPermanently(
|
||||
{ handles }: { handles: FileSystemHandle[] },
|
||||
) {
|
||||
// Collect all items to delete (including nested items)
|
||||
const { fileHandles: fileHandlesToDelete, directoryHandles: directoryHandlesToDelete } =
|
||||
await collectAllHandlesRecursively(ctx, { handles })
|
||||
const {
|
||||
fileHandles: fileHandlesToDelete,
|
||||
directoryHandles: directoryHandlesToDelete,
|
||||
} = await collectAllHandlesRecursively(ctx, { handles })
|
||||
|
||||
// Delete files and directories using their respective models
|
||||
const [filesResult, directoriesResult] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user