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