mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-07 16:34:26 +00:00
Remove FileList, FileOps and GitOps contexts
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { useEffect, useCallback } from 'react';
|
||||
import { useFileSelection } from './useFileSelection';
|
||||
import { useFileContent } from './useFileContent';
|
||||
import { useFileOperations } from './useFileOperations';
|
||||
|
||||
export const useFileManagement = () => {
|
||||
const { selectedFile, isNewFile, handleFileSelect } = useFileSelection();
|
||||
@@ -12,10 +11,7 @@ export const useFileManagement = () => {
|
||||
hasUnsavedChanges,
|
||||
loadFileContent,
|
||||
handleContentChange,
|
||||
setHasUnsavedChanges,
|
||||
} = useFileContent();
|
||||
const { handleSave, handleDelete, handleCreateNewFile } =
|
||||
useFileOperations(setHasUnsavedChanges);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedFile) {
|
||||
@@ -40,8 +36,5 @@ export const useFileManagement = () => {
|
||||
hasUnsavedChanges,
|
||||
handleFileSelect: handleFileSelectAndLoad,
|
||||
handleContentChange,
|
||||
handleSave: (filePath) => handleSave(filePath, content),
|
||||
handleDelete,
|
||||
handleCreateNewFile,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ export const useFileNavigation = () => {
|
||||
handleFileSelect(filePaths[0]);
|
||||
} else if (filePaths.length > 1) {
|
||||
// Handle multiple file options (you may want to show a modal or dropdown)
|
||||
console.log('Multiple files found:', filePaths);
|
||||
setToast({
|
||||
text: 'Multiple files found with the same name. Please specify the full path.',
|
||||
type: 'warning',
|
||||
|
||||
@@ -32,19 +32,16 @@ export const useFileOperations = (setHasUnsavedChanges) => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleCreateNewFile = useCallback(
|
||||
async (fileName, initialContent = '') => {
|
||||
try {
|
||||
await saveFileContent(fileName, initialContent);
|
||||
return true;
|
||||
} catch (error) {
|
||||
setToast({ text: `Error creating new file`, type: 'error' });
|
||||
console.error('Error creating new file:', error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
const handleCreate = useCallback(async (fileName, initialContent = '') => {
|
||||
try {
|
||||
await saveFileContent(fileName, initialContent);
|
||||
return true;
|
||||
} catch (error) {
|
||||
setToast({ text: `Error creating new file`, type: 'error' });
|
||||
console.error('Error creating new file:', error);
|
||||
return false;
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { handleSave, handleDelete, handleCreateNewFile };
|
||||
return { handleSave, handleDelete, handleCreate };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user