mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Fix duplicate file list requests
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user