Skip to content

Commit

Permalink
trying to set up delete function removed the warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
greeenboi committed Feb 5, 2024
1 parent 704c7c2 commit 5f7de3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
34 changes: 17 additions & 17 deletions src-tauri/src/fc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ pub fn write_file(path: &str, content: &str) -> String {
result
}

pub fn create_directory(path: &str) -> Result<()>{
let dir_path = Path::new(path);
fs::create_dir(dir_path);
Ok(())
}

pub fn remove_file(path: &str) -> Result<()> {
let file_path = Path::new(path);
fs::remove_file(file_path);
Ok(())
}

pub fn remove_folder(path: &str) -> Result<()>{
let folder_path = Path::new(path);
fs::remove_dir_all(folder_path);
Ok(())
}
// pub fn create_directory(path: &str) -> Result<()>{
// let dir_path = Path::new(path);
// fs::create_dir(dir_path);
// Ok(())
// }

// pub fn remove_file(path: &str) -> Result<()> {
// let file_path = Path::new(path);
// fs::remove_file(file_path);
// Ok(())
// }

// pub fn remove_folder(path: &str) -> Result<()>{
// let folder_path = Path::new(path);
// fs::remove_dir_all(folder_path);
// Ok(())
// }
13 changes: 10 additions & 3 deletions src/components/NavFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ export default function NavFiles({ files, visible} : Props) {
const {setSelect, selected, addOpenedFile} = useSource();
const onShow = async (e: React.MouseEvent<HTMLDivElement, MouseEvent>, file: IFile) =>{
e.stopPropagation();
console.log(file.id);
if(file.kind === 'file'){
setSelect(file.id);
addOpenedFile(file.id);
}
}

// const handleDeleteFile = (path: string) => {

// }

return(
<div className={`source-codes ${visible ? '' : 'hidden'}`}>
Expand All @@ -29,9 +33,12 @@ export default function NavFiles({ files, visible} : Props) {
)
}
return(
<div onClick={(e) => onShow(e, file)} key={file.id} className={`source-item ${isSelected ? 'source-item-active' : ''} flex items-center gap-2 px-4 py-0.5 text-[#AEAEAE] hover:text-gray-300 cursor-pointer active:border border-gray-600 hover:bg-gray-500 my-1 ease-in-out transition-all `}>
<FileIcon name={file.name} />
<span className="text-sm">{file.name}</span>
<div onClick={(e) => onShow(e, file)} key={file.id} className={`w-full source-item ${isSelected ? 'source-item-active' : ''} flex flex-row justify-between items-center px-4 py-0.5 text-[#AEAEAE] hover:text-gray-300 cursor-pointer active:border border-gray-600 hover:bg-gray-500 my-1 ease-in-out transition-all `}>
<div className="flex flex-row gap-1">
<FileIcon name={file.name} />
<span className="text-sm">{file.name}</span>
</div>
{/* <i className="ri-delete-bin-6-line text-gray-500 hover:text-red-700" onClick={}></i> */}
</div>
)
})}
Expand Down
6 changes: 3 additions & 3 deletions src/context/SourceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ interface ISourceContext {

const SourceContext = createContext<ISourceContext>({
selected: '',
setSelect:(id) => {},
setSelect:(id) => {id},
opened: [],
addOpenedFile: (id) => {},
deleteOpenedFile: (id) => {},
addOpenedFile: (id) => {id},
deleteOpenedFile: (id) => {id},
});


Expand Down

0 comments on commit 5f7de3d

Please sign in to comment.