diff --git a/frontend/components/editor/sidebar/index.tsx b/frontend/components/editor/sidebar/index.tsx index a5dca5f..e0b8c86 100644 --- a/frontend/components/editor/sidebar/index.tsx +++ b/frontend/components/editor/sidebar/index.tsx @@ -11,7 +11,7 @@ import { import SidebarFile from "./file" import SidebarFolder from "./folder" import { Sandbox, TFile, TFolder, TTab } from "@/lib/types" -import { useEffect, useRef, useState } from "react" +import { useEffect, useMemo, useRef, useState } from "react" import New from "./new" import { Socket } from "socket.io-client" import { Switch } from "@/components/ui/switch" @@ -22,6 +22,7 @@ import { } from "@atlaskit/pragmatic-drag-and-drop/element/adapter" import Button from "@/components/ui/customButton" import { Skeleton } from "@/components/ui/skeleton" +import { sortFileExplorer } from "@/lib/utils" export default function Sidebar({ sandboxData, @@ -55,7 +56,9 @@ export default function Sidebar({ const [creatingNew, setCreatingNew] = useState<"file" | "folder" | null>(null) const [movingId, setMovingId] = useState("") - console.log(files) + const sortedFiles = useMemo(() => { + return sortFileExplorer(files) + }, [files]) useEffect(() => { const el = ref.current @@ -136,7 +139,7 @@ export default function Sidebar({ isDraggedOver ? "bg-secondary/50" : "" } rounded-sm w-full mt-1 flex flex-col`} > */} - {files.length === 0 ? ( + {sortedFiles.length === 0 ? (