diff --git a/lightrag_webui/src/App.tsx b/lightrag_webui/src/App.tsx index a436b279..6760375c 100644 --- a/lightrag_webui/src/App.tsx +++ b/lightrag_webui/src/App.tsx @@ -35,18 +35,18 @@ function App() { // Track component mount status with useRef const isMountedRef = useRef(true); - + // Set up mount/unmount status tracking useEffect(() => { isMountedRef.current = true; - + // Handle page reload/unload const handleBeforeUnload = () => { isMountedRef.current = false; }; - + window.addEventListener('beforeunload', handleBeforeUnload); - + return () => { isMountedRef.current = false; window.removeEventListener('beforeunload', handleBeforeUnload); diff --git a/lightrag_webui/src/components/ui/FileUploader.tsx b/lightrag_webui/src/components/ui/FileUploader.tsx index 9868acc6..3953e0b0 100644 --- a/lightrag_webui/src/components/ui/FileUploader.tsx +++ b/lightrag_webui/src/components/ui/FileUploader.tsx @@ -210,7 +210,7 @@ function FileUploader(props: FileUploaderProps) { if (!file.name) { return false; } - + // Check if file type is accepted const fileExt = `.${file.name.split('.').pop()?.toLowerCase() || ''}`; const isAccepted = Object.entries(accept || {}).some(([mimeType, extensions]) => { @@ -269,14 +269,14 @@ function FileUploader(props: FileUploaderProps) { if (!file.name) { return { code: 'invalid-file-name', - message: t('documentPanel.uploadDocuments.fileUploader.invalidFileName', + message: t('documentPanel.uploadDocuments.fileUploader.invalidFileName', { fallback: 'Invalid file name' }) }; } - + // Safely extract file extension const fileExt = `.${file.name.split('.').pop()?.toLowerCase() || ''}`; - + // Ensure accept object exists and has correct format const isAccepted = Object.entries(accept || {}).some(([mimeType, extensions]) => { // Ensure extensions is an array before calling includes diff --git a/lightrag_webui/src/features/DocumentManager.tsx b/lightrag_webui/src/features/DocumentManager.tsx index 533756b3..ecb163c1 100644 --- a/lightrag_webui/src/features/DocumentManager.tsx +++ b/lightrag_webui/src/features/DocumentManager.tsx @@ -139,24 +139,24 @@ type SortDirection = 'asc' | 'desc'; export default function DocumentManager() { // Track component mount status const isMountedRef = useRef(true); - + // Set up mount/unmount status tracking useEffect(() => { isMountedRef.current = true; - + // Handle page reload/unload const handleBeforeUnload = () => { isMountedRef.current = false; }; - + window.addEventListener('beforeunload', handleBeforeUnload); - + return () => { isMountedRef.current = false; window.removeEventListener('beforeunload', handleBeforeUnload); }; }, []); - + const [showPipelineStatus, setShowPipelineStatus] = useState(false) const { t } = useTranslation() const health = useBackendState.use.health() @@ -346,9 +346,9 @@ export default function DocumentManager() { try { // Check if component is still mounted before starting the request if (!isMountedRef.current) return; - + const docs = await getDocuments(); - + // Check again if component is still mounted after the request completes if (!isMountedRef.current) return; @@ -409,12 +409,12 @@ export default function DocumentManager() { try { // Check if component is still mounted before starting the request if (!isMountedRef.current) return; - + const { status } = await scanNewDocuments(); - + // Check again if component is still mounted after the request completes if (!isMountedRef.current) return; - + toast.message(status); } catch (err) { // Only show error if component is still mounted