fix: broken dir path breadcrumb links

This commit is contained in:
2025-10-05 15:01:55 +00:00
parent 33b235517c
commit b654f50ddd
5 changed files with 48 additions and 18 deletions

View File

@@ -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(

View File

@@ -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([