11import {
22 memo ,
33 useCallback ,
4+ useContext ,
45 useEffect ,
56 useRef ,
67 useState ,
7- useContext ,
88} from "react" ;
99import { useNavigate } from "react-router-dom" ;
1010import { Grid , List , StepBackIcon } from "lucide-react" ;
@@ -19,7 +19,7 @@ import DownloadButton from "@/Pages/Drive/Components/DownloadButton.jsx";
1919import ShowShareModalButton from "@/Pages/Drive/Components/Shares/ShowShareModalButton.jsx" ;
2020import DeleteButton from "@/Pages/Drive/Components/DeleteButton.jsx" ;
2121import UploadMenu from "@/Pages/Drive/Components/UploadMenu.jsx" ;
22- import { usePage , router } from "@inertiajs/react" ;
22+ import { router , usePage } from "@inertiajs/react" ;
2323import RenameModal from "@/Pages/Drive/Components/FileList/RenameModal.jsx" ;
2424import CutButton from "./CutButton.jsx" ;
2525import PasteButton from "./PasteButton.jsx" ;
@@ -45,7 +45,8 @@ const FileBrowserSection = memo(({ files, path, token, isAdmin, slug }) => {
4545 const [ fileToRename , setFileToRename ] = useState ( new Set ( ) ) ;
4646 const [ isRenameModalOpen , setIsRenameModalOpen ] = useState ( false ) ;
4747
48- const { cutFiles, setCutFiles, cutPath, setCutPath } = useContext ( CutFilesContext ) ;
48+ const { cutFiles, setCutFiles, cutPath, setCutPath } =
49+ useContext ( CutFilesContext ) ;
4950
5051 const handleCut = ( ) => {
5152 setCutFiles ?. ( new Set ( selectedFiles ) ) ;
@@ -120,8 +121,13 @@ const FileBrowserSection = memo(({ files, path, token, isAdmin, slug }) => {
120121
121122 function sortArrayByKey ( arr , key , direction ) {
122123 return [ ...arr ] . sort ( ( a , b ) => {
123- const valA = a [ key ] ?. toLowerCase ?. ( ) || a [ key ] || "" ;
124- const valB = b [ key ] ?. toLowerCase ?. ( ) || b [ key ] || "" ;
124+ let valA =
125+ a [ key ] ?. toLowerCase ?. ( ) || ( a [ key ] != null ? a [ key ] : "" ) ;
126+ let valB =
127+ b [ key ] ?. toLowerCase ?. ( ) || ( b [ key ] != null ? b [ key ] : "" ) ;
128+ // empty string are for folders sizes
129+ valA = valA === "" ? - 1 : valA ;
130+ valB = valB === "" ? - 1 : valB ;
125131
126132 if ( direction === "desc" ) {
127133 return valA > valB ? - 1 : valA < valB ? 1 : 0 ;
0 commit comments