From 49c68e3f7786111bd3f56e228a958e55c377ea5d Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sat, 5 Oct 2024 10:18:59 +0200 Subject: [PATCH] Remove debug console logs --- frontend/src/components/Editor.js | 6 ------ frontend/src/contexts/EditorContentContext.js | 7 ------- frontend/src/contexts/FileSelectionContext.js | 2 -- frontend/src/hooks/useFileOperations.js | 10 +++++++--- frontend/src/hooks/useFileSelection.js | 1 - 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/Editor.js b/frontend/src/components/Editor.js index 8e84b6e..d9554ca 100644 --- a/frontend/src/components/Editor.js +++ b/frontend/src/components/Editor.js @@ -77,13 +77,7 @@ const Editor = () => { }, [selectedFile, settings.theme, handleContentChange, handleSave]); useEffect(() => { - console.log('Editor: content or selectedFile changed', { - content, - selectedFile, - }); - if (viewRef.current && content !== viewRef.current.state.doc.toString()) { - console.log('Editor: updating content in CodeMirror'); viewRef.current.dispatch({ changes: { from: 0, diff --git a/frontend/src/contexts/EditorContentContext.js b/frontend/src/contexts/EditorContentContext.js index 2ab0fdc..b77128c 100644 --- a/frontend/src/contexts/EditorContentContext.js +++ b/frontend/src/contexts/EditorContentContext.js @@ -7,13 +7,6 @@ export const EditorContentProvider = ({ children }) => { const { content, handleContentChange, handleSave, selectedFile } = useFileManagementContext(); - useEffect(() => { - console.log('EditorContentProvider: content or selectedFile updated', { - content, - selectedFile, - }); - }, [content, selectedFile]); - return ( { const { selectedFile, handleFileSelect } = useFileManagementContext(); - console.log('FileSelectionProvider rendering', { selectedFile }); - return ( {children} diff --git a/frontend/src/hooks/useFileOperations.js b/frontend/src/hooks/useFileOperations.js index beebeae..18cc0f7 100644 --- a/frontend/src/hooks/useFileOperations.js +++ b/frontend/src/hooks/useFileOperations.js @@ -1,13 +1,16 @@ import { useCallback } from 'react'; import { saveFileContent, deleteFile } from '../services/api'; +import { useToasts } from '@geist-ui/core'; export const useFileOperations = (setHasUnsavedChanges) => { + const { setToast } = useToasts(); + const handleSave = useCallback( async (filePath, content) => { try { await saveFileContent(filePath, content); setHasUnsavedChanges(false); - console.log('File saved successfully'); + setToast({ text: 'File saved successfully', type: 'success' }); return true; } catch (error) { console.error('Error saving file:', error); @@ -20,9 +23,10 @@ export const useFileOperations = (setHasUnsavedChanges) => { const handleDelete = useCallback(async (filePath) => { try { await deleteFile(filePath); - console.log('File deleted successfully'); + setToast({ text: 'File deleted successfully', type: 'success' }); return true; } catch (error) { + setToast({ text: `Error deleting file`, type: 'error' }); console.error('Error deleting file:', error); return false; } @@ -32,9 +36,9 @@ export const useFileOperations = (setHasUnsavedChanges) => { async (fileName, initialContent = '') => { try { await saveFileContent(fileName, initialContent); - console.log('New file created successfully'); return true; } catch (error) { + setToast({ text: `Error creating new file`, type: 'error' }); console.error('Error creating new file:', error); return false; } diff --git a/frontend/src/hooks/useFileSelection.js b/frontend/src/hooks/useFileSelection.js index 6fa7d01..8b23ac5 100644 --- a/frontend/src/hooks/useFileSelection.js +++ b/frontend/src/hooks/useFileSelection.js @@ -6,7 +6,6 @@ export const useFileSelection = () => { const [isNewFile, setIsNewFile] = useState(true); const handleFileSelect = useCallback(async (filePath) => { - console.log('File selected:', filePath); setSelectedFile(filePath); setIsNewFile(filePath === DEFAULT_FILE.path); }, []);