fixed create dir path again

This commit is contained in:
Niklas 2021-08-24 15:03:30 +02:00
parent a716b4c8cd
commit e06d28d75e
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import React from "react" import React from "react"
import { useState } from "react" import { useState } from "react"
import { useContextMenu } from "react-contexify" import { useContextMenu } from "react-contexify"
import normalizeDirPath from "../functions/normalizeDirPath"
import uploadFile from "../functions/uploadFile" import uploadFile from "../functions/uploadFile"
import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql"
import Breadcrum from "./Breadcrum" import Breadcrum from "./Breadcrum"
@ -117,7 +118,8 @@ const FileBrowser: React.FC = () => {
<div className="ml-auto"> <div className="ml-auto">
<CreateDirButton <CreateDirButton
onPressed={async (dirName)=>{ onPressed={async (dirName)=>{
await createDirMutation({variables:{path:path + dirName}}) const fullPath = normalizeDirPath(normalizeDirPath(path) + dirName)
await createDirMutation({variables:{path: fullPath}})
refetchDir() refetchDir()
}} }}
/> />

View File

@ -0,0 +1,5 @@
function normalizeDirPath(path:string): string {
return path.endsWith("/")?path: (path + "/")
}
export default normalizeDirPath