Skip to content

Commit

Permalink
fix: issue with duplicate ids
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Sep 1, 2024
1 parent 9fc169b commit f5a19cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/workspace/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { usePathname, useSearchParams } from "next/navigation";
import useSWR, { mutate } from "swr";
import { FileIcon } from "./file-icon";
import { FileExplorerTopMenu } from "./file-explorer-top-menu";
import TreeView, { flattenTree } from "react-accessible-treeview";

type TOCProps = {
toc: TreeViewElement[];
Expand Down Expand Up @@ -91,7 +92,7 @@ function convert(data: string[]) {
path += "/" + label;
let node = map.get(path);
if (!node) {
map.set(path, (node = { id: name, name: label } as TreeViewElement));
map.set(path, (node = { id: path, name: label } as TreeViewElement));
(parent.children ??= []).push(node);
}
parent = node;
Expand All @@ -115,6 +116,8 @@ const FileExplorer = () => {
);
});

console.log(toc);

if (!toc) return <p>Loading...</p>;

return (
Expand Down

0 comments on commit f5a19cb

Please sign in to comment.