diff --git a/frontend/src/components/MainContent.js b/frontend/src/components/MainContent.js index 0d7b56a..1af82a4 100644 --- a/frontend/src/components/MainContent.js +++ b/frontend/src/components/MainContent.js @@ -14,9 +14,11 @@ import { useFileList } from '../hooks/useFileList'; import { useFileOperations } from '../hooks/useFileOperations'; import { useGitOperations } from '../hooks/useGitOperations'; import { useFileNavigation } from '../hooks/useFileNavigation'; +import { useSettings } from '../contexts/SettingsContext'; const MainContent = () => { const [activeTab, setActiveTab] = useState('source'); + const { settings } = useSettings(); const { files, loadFileList } = useFileList(); const { handleLinkClick, selectedFile, handleFileSelect } = useFileNavigation(); @@ -31,7 +33,7 @@ const MainContent = () => { useEffect(() => { loadFileList(); - }, [loadFileList]); + }, [settings.gitEnabled]); const handleTabChange = (value) => { setActiveTab(value); diff --git a/frontend/src/contexts/SettingsContext.js b/frontend/src/contexts/SettingsContext.js index 5caf883..255c755 100644 --- a/frontend/src/contexts/SettingsContext.js +++ b/frontend/src/contexts/SettingsContext.js @@ -1,5 +1,6 @@ import React, { createContext, useState, useContext, useEffect } from 'react'; import { fetchUserSettings, saveUserSettings } from '../services/api'; +import { DEFAULT_SETTINGS } from '../utils/constants'; const SettingsContext = createContext(); @@ -8,17 +9,7 @@ export const useSettings = () => { }; export const SettingsProvider = ({ children }) => { - const [settings, setSettings] = useState({ - theme: 'light', - autoSave: false, - gitEnabled: false, - gitUrl: '', - gitUser: '', - gitToken: '', - gitAutoCommit: false, - gitCommitMsgTemplate: '', - }); - + const [settings, setSettings] = useState(DEFAULT_SETTINGS); const [loading, setLoading] = useState(true); useEffect(() => { diff --git a/frontend/src/hooks/useFileList.js b/frontend/src/hooks/useFileList.js index 0a37baf..0c5a285 100644 --- a/frontend/src/hooks/useFileList.js +++ b/frontend/src/hooks/useFileList.js @@ -1,7 +1,7 @@ import { useState, useEffect, useCallback } from 'react'; import { fetchFileList } from '../services/api'; -export const useFileList = (gitEnabled) => { +export const useFileList = () => { const [files, setFiles] = useState([]); const loadFileList = useCallback(async () => { @@ -17,9 +17,5 @@ export const useFileList = (gitEnabled) => { } }, []); - useEffect(() => { - loadFileList(); - }, [gitEnabled]); - return { files, loadFileList }; };