mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Fix file list loading
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { fetchFileList } from '../services/api';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
|
||||
export const useFileList = () => {
|
||||
const [files, setFiles] = useState([]);
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentWorkspace, loading: workspaceLoading } = useWorkspace();
|
||||
|
||||
const loadFileList = useCallback(async () => {
|
||||
if (!currentWorkspace) return;
|
||||
if (!currentWorkspace || workspaceLoading) return;
|
||||
|
||||
try {
|
||||
const fileList = await fetchFileList(currentWorkspace.id);
|
||||
@@ -18,8 +18,9 @@ export const useFileList = () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load file list:', error);
|
||||
setFiles([]);
|
||||
}
|
||||
}, [currentWorkspace]);
|
||||
}, [currentWorkspace, workspaceLoading]);
|
||||
|
||||
return { files, loadFileList };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user