Skip to content

Commit

Permalink
fix nested directory path
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog-crabnebula committed Nov 16, 2023
1 parent ff92442 commit 124d742
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions web-client/src/components/sources/directory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { Loader } from "~/components/loader";

type DirectoryProps = {
parent?: Entry["path"];
defaultPath: Entry["path"];
defaultSize: Entry["size"];
defaultFileType: Entry["fileType"];
Expand All @@ -40,22 +41,23 @@ const liStyles = "hover:bg-gray-800 hover:text-white focus:bg-gray-800";

export function Directory(props: DirectoryProps) {
const { client } = useRouteData<Connection>();
const [entries] = awaitEntries(client.sources, props.defaultPath);
const path = props.parent ? `${props.parent}/${props.defaultPath}` : props.defaultPath;
const [entries] = awaitEntries(client.sources, path);
const sortedEntries = () => entries()?.sort(sortByPath);

return (
<Suspense fallback={<Loader />}>
<ul class={props.class}>
<For each={sortedEntries()} fallback={<li>Empty</li>}>
{(child) => {
const absolutePath = [props.defaultPath, child.path]
const absolutePath = [path, child.path]
.filter((e) => !!e)
.join("/");
const [isOpen, setIsOpen] = createSignal(false);

if (isDirectory(child)) {
const defaultProps = {
path: props.defaultPath,
path,
size: props.defaultSize,
fileType: props.defaultFileType,
};
Expand All @@ -78,6 +80,7 @@ export function Directory(props: DirectoryProps) {
<Collapsible.Content>
<div class="pl-4">
<Directory
parent={path}
defaultPath={childProps.path}
defaultSize={childProps.size}
defaultFileType={childProps.fileType}
Expand Down

0 comments on commit 124d742

Please sign in to comment.