From cbaa945b7e7685b01a2b9a1ca3ceab6d81121df6 Mon Sep 17 00:00:00 2001 From: Reece Browne Date: Thu, 21 Aug 2025 16:43:01 +0100 Subject: [PATCH] File editor clean up and fix infinite loop --- .../src/components/fileEditor/FileEditor.tsx | 70 ++++----- .../tools/convert/ConvertSettings.tsx | 4 +- frontend/src/contexts/FileContext.tsx | 5 +- frontend/src/contexts/file/fileHooks.ts | 43 ++---- .../tools/convert/useConvertParameters.ts | 134 +++++++++++++----- frontend/src/pages/HomePage.tsx | 16 +-- frontend/src/tools/AddPassword.tsx | 4 +- frontend/src/tools/AddWatermark.tsx | 4 +- frontend/src/tools/ChangePermissions.tsx | 4 +- frontend/src/tools/Compress.tsx | 4 +- frontend/src/tools/Convert.tsx | 7 +- frontend/src/tools/OCR.tsx | 4 +- frontend/src/tools/RemoveCertificateSign.tsx | 4 +- frontend/src/tools/RemovePassword.tsx | 4 +- frontend/src/tools/Repair.tsx | 4 +- frontend/src/tools/Sanitize.tsx | 4 +- frontend/src/tools/SingleLargePage.tsx | 4 +- frontend/src/tools/Split.tsx | 4 +- frontend/src/tools/UnlockPdfForms.tsx | 4 +- 19 files changed, 165 insertions(+), 162 deletions(-) diff --git a/frontend/src/components/fileEditor/FileEditor.tsx b/frontend/src/components/fileEditor/FileEditor.tsx index b5160b9f5..c93e78670 100644 --- a/frontend/src/components/fileEditor/FileEditor.tsx +++ b/frontend/src/components/fileEditor/FileEditor.tsx @@ -6,7 +6,7 @@ import { import { Dropzone } from '@mantine/dropzone'; import { useTranslation } from 'react-i18next'; import UploadFileIcon from '@mui/icons-material/UploadFile'; -import { useToolFileSelection, useFileState, useFileManagement, useFileActions } from '../../contexts/FileContext'; +import { useFileSelection, useFileState, useFileManagement, useFileActions } from '../../contexts/FileContext'; import { useNavigationActions } from '../../contexts/NavigationContext'; import { FileOperation } from '../../types/fileContext'; import { fileStorage } from '../../services/fileStorage'; @@ -58,26 +58,8 @@ const FileEditor = ({ const { actions } = useFileActions(); const { actions: navActions } = useNavigationActions(); - // Proper context-based file selection updater - const setContextSelectedFiles = useCallback((fileIds: string[] | ((prev: string[]) => string[])) => { - if (typeof fileIds === 'function') { - // Handle callback pattern with current state - const result = fileIds(selectedFileIds); - actions.setSelectedFiles(result); - } else { - // Handle direct array pattern - actions.setSelectedFiles(fileIds); - } - }, [selectedFileIds, actions.setSelectedFiles]); - - - // Get tool file selection context (replaces FileSelectionContext) - const { - selectedFiles: toolSelectedFiles, - setSelectedFiles: setToolSelectedFiles, - maxFiles, - isToolMode - } = useToolFileSelection(); + // Get file selection context + const { setSelectedFiles } = useFileSelection(); const [status, setStatus] = useState(null); const [error, setError] = useState(null); @@ -271,10 +253,10 @@ const FileEditor = ({ }, [addFiles]); const selectAll = useCallback(() => { - setContextSelectedFiles(activeFileRecords.map(r => r.id)); // Use FileRecord IDs directly - }, [activeFileRecords, setContextSelectedFiles]); + setSelectedFiles(activeFileRecords.map(r => r.id)); // Use FileRecord IDs directly + }, [activeFileRecords, setSelectedFiles]); - const deselectAll = useCallback(() => setContextSelectedFiles([]), [setContextSelectedFiles]); + const deselectAll = useCallback(() => setSelectedFiles([]), [setSelectedFiles]); const closeAllFiles = useCallback(() => { if (activeFileRecords.length === 0) return; @@ -284,8 +266,8 @@ const FileEditor = ({ removeFiles(allFileIds, false); // false = keep in storage // Clear selections - setContextSelectedFiles([]); - }, [activeFileRecords, removeFiles, setContextSelectedFiles]); + setSelectedFiles([]); + }, [activeFileRecords, removeFiles, setSelectedFiles]); const toggleFile = useCallback((fileId: string) => { const currentSelectedIds = contextSelectedIdsRef.current; @@ -303,36 +285,34 @@ const FileEditor = ({ newSelection = currentSelectedIds.filter(id => id !== contextFileId); } else { // Add file to selection - if (maxFiles === 1) { + // In tool mode, typically allow multiple files unless specified otherwise + const maxAllowed = toolMode ? 10 : Infinity; // Default max for tools + + if (maxAllowed === 1) { newSelection = [contextFileId]; } else { // Check if we've hit the selection limit - if (maxFiles > 1 && currentSelectedIds.length >= maxFiles) { - setStatus(`Maximum ${maxFiles} files can be selected`); + if (maxAllowed > 1 && currentSelectedIds.length >= maxAllowed) { + setStatus(`Maximum ${maxAllowed} files can be selected`); return; } newSelection = [...currentSelectedIds, contextFileId]; } } - // Update context - setContextSelectedFiles(newSelection); - - // Update tool selection context if in tool mode - if (isToolMode || toolMode) { - setToolSelectedFiles(newSelection); - } - }, [setContextSelectedFiles, maxFiles, setStatus, isToolMode, toolMode, setToolSelectedFiles, activeFileRecords]); + // Update context (this automatically updates tool selection since they use the same action) + setSelectedFiles(newSelection); + }, [setSelectedFiles, toolMode, setStatus, activeFileRecords]); const toggleSelectionMode = useCallback(() => { setSelectionMode(prev => { const newMode = !prev; if (!newMode) { - setContextSelectedFiles([]); + setSelectedFiles([]); } return newMode; }); - }, [setContextSelectedFiles]); + }, [setSelectedFiles]); // File reordering handler for drag and drop const handleReorderFiles = useCallback((sourceFileId: string, targetFileId: string, selectedFileIds: string[]) => { @@ -422,21 +402,19 @@ const FileEditor = ({ removeFiles([contextFileId], false); // Remove from context selections - setContextSelectedFiles((prev: string[]) => { - const safePrev = Array.isArray(prev) ? prev : []; - return safePrev.filter(id => id !== contextFileId); - }); + const currentSelected = selectedFileIds.filter(id => id !== contextFileId); + setSelectedFiles(currentSelected); } - }, [activeFileRecords, selectors, removeFiles, setContextSelectedFiles]); + }, [activeFileRecords, selectors, removeFiles, setSelectedFiles, selectedFileIds]); const handleViewFile = useCallback((fileId: string) => { const record = activeFileRecords.find(r => r.id === fileId); if (record) { // Set the file as selected in context and switch to viewer for preview - setContextSelectedFiles([fileId]); + setSelectedFiles([fileId]); navActions.setMode('viewer'); } - }, [activeFileRecords, setContextSelectedFiles, navActions.setMode]); + }, [activeFileRecords, setSelectedFiles, navActions.setMode]); const handleMergeFromHere = useCallback((fileId: string) => { const startIndex = activeFileRecords.findIndex(r => r.id === fileId); diff --git a/frontend/src/components/tools/convert/ConvertSettings.tsx b/frontend/src/components/tools/convert/ConvertSettings.tsx index f1f079c1a..bec6b272f 100644 --- a/frontend/src/components/tools/convert/ConvertSettings.tsx +++ b/frontend/src/components/tools/convert/ConvertSettings.tsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import { useMultipleEndpointsEnabled } from "../../../hooks/useEndpointConfig"; import { isImageFormat, isWebFormat } from "../../../utils/convertUtils"; import { getConversionEndpoints } from "../../../data/toolsTaxonomy"; -import { useToolFileSelection } from "../../../contexts/FileContext"; +import { useFileSelection } from "../../../contexts/FileContext"; import { useFileState } from "../../../contexts/FileContext"; import { detectFileExtension } from "../../../utils/fileUtils"; import GroupedFormatDropdown from "./GroupedFormatDropdown"; @@ -41,7 +41,7 @@ const ConvertSettings = ({ const { t } = useTranslation(); const theme = useMantineTheme(); const { colorScheme } = useMantineColorScheme(); - const { setSelectedFiles } = useToolFileSelection(); + const { setSelectedFiles } = useFileSelection(); const { state, selectors } = useFileState(); const activeFiles = state.files.ids; diff --git a/frontend/src/contexts/FileContext.tsx b/frontend/src/contexts/FileContext.tsx index c382cce78..44adf6b28 100644 --- a/frontend/src/contexts/FileContext.tsx +++ b/frontend/src/contexts/FileContext.tsx @@ -7,7 +7,7 @@ * Key hooks: * - useFileState() - access file state and UI state * - useFileActions() - file operations (add/remove/update) - * - useToolFileSelection() - for tool components + * - useFileSelection() - for file selection state and actions * * Memory management handled by FileLifecycleManager (PDF.js cleanup, blob URL revocation). */ @@ -275,6 +275,5 @@ export { useAllFiles, useSelectedFiles, // Primary API hooks for tools - useFileContext, - useToolFileSelection + useFileContext } from './file/fileHooks'; \ No newline at end of file diff --git a/frontend/src/contexts/file/fileHooks.ts b/frontend/src/contexts/file/fileHooks.ts index 6a7ccfa6f..19452958f 100644 --- a/frontend/src/contexts/file/fileHooks.ts +++ b/frontend/src/contexts/file/fileHooks.ts @@ -51,16 +51,23 @@ export function useCurrentFile(): { file?: File; record?: FileRecord } { * Hook for file selection state and actions */ export function useFileSelection() { - const { state } = useFileState(); + const { state, selectors } = useFileState(); const { actions } = useFileActions(); + // Memoize selected files to avoid recreating arrays + const selectedFiles = useMemo(() => { + return selectors.getSelectedFiles(); + }, [state.ui.selectedFileIds, selectors]); + return useMemo(() => ({ + selectedFiles, selectedFileIds: state.ui.selectedFileIds, selectedPageNumbers: state.ui.selectedPageNumbers, setSelectedFiles: actions.setSelectedFiles, setSelectedPages: actions.setSelectedPages, clearSelections: actions.clearSelections }), [ + selectedFiles, state.ui.selectedFileIds, state.ui.selectedPageNumbers, actions.setSelectedFiles, @@ -183,38 +190,4 @@ export function useFileContext() { }), [state, selectors, actions]); } -/** - * Primary API hook for tool file selection workflow - * Used by tools for managing file selection and tool-specific operations - */ -export function useToolFileSelection() { - const { state, selectors } = useFileState(); - const { actions } = useFileActions(); - - // Memoize selected files to avoid recreating arrays - const selectedFiles = useMemo(() => { - return selectors.getSelectedFiles(); - }, [state.ui.selectedFileIds, selectors]); - - return useMemo(() => ({ - selectedFiles, - selectedFileIds: state.ui.selectedFileIds, - selectedPageNumbers: state.ui.selectedPageNumbers, - setSelectedFiles: actions.setSelectedFiles, - setSelectedPages: actions.setSelectedPages, - clearSelections: actions.clearSelections, - // Tool workflow properties - maxFiles: 10, // Default value for tools - isToolMode: true, - setMaxFiles: (maxFiles: number) => { /* Tool-specific - can be implemented if needed */ }, - setIsToolMode: (isToolMode: boolean) => { /* Tool-specific - can be implemented if needed */ } - }), [ - selectedFiles, - state.ui.selectedFileIds, - state.ui.selectedPageNumbers, - actions.setSelectedFiles, - actions.setSelectedPages, - actions.clearSelections - ]); -} diff --git a/frontend/src/hooks/tools/convert/useConvertParameters.ts b/frontend/src/hooks/tools/convert/useConvertParameters.ts index 64ba7a38e..4d04dd8f0 100644 --- a/frontend/src/hooks/tools/convert/useConvertParameters.ts +++ b/frontend/src/hooks/tools/convert/useConvertParameters.ts @@ -12,6 +12,7 @@ import { getEndpointName as getEndpointNameUtil, getEndpointUrl, isImageFormat, import { detectFileExtension as detectFileExtensionUtil } from '../../../utils/fileUtils'; import { BaseParameters } from '../../../types/parameters'; import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters'; +import { useCallback, useMemo } from 'react'; export interface ConvertParameters extends BaseParameters { fromExtension: string; @@ -121,11 +122,13 @@ const getEndpointName = (params: ConvertParameters): string => { }; export const useConvertParameters = (): ConvertParametersHook => { - const baseHook = useBaseParameters({ + const config = useMemo(() => ({ defaultParameters, endpointName: getEndpointName, validateFn: validateParameters, - }); + }), []); + + const baseHook = useBaseParameters(config); const getEndpoint = () => { const { fromExtension, toExtension, isSmartDetection, smartDetectionType } = baseHook.parameters; @@ -178,15 +181,22 @@ export const useConvertParameters = (): ConvertParametersHook => { }; - const analyzeFileTypes = (files: Array<{name: string}>) => { + const analyzeFileTypes = useCallback((files: Array<{name: string}>) => { if (files.length === 0) { // No files - only reset smart detection, keep user's format choices - baseHook.setParameters(prev => ({ - ...prev, - isSmartDetection: false, - smartDetectionType: 'none' - // Don't reset fromExtension and toExtension - let user keep their choices - })); + baseHook.setParameters(prev => { + // Only update if something actually changed + if (prev.isSmartDetection === false && prev.smartDetectionType === 'none') { + return prev; // No change needed + } + + return { + ...prev, + isSmartDetection: false, + smartDetectionType: 'none' + // Don't reset fromExtension and toExtension - let user keep their choices + }; + }); return; } @@ -221,13 +231,25 @@ export const useConvertParameters = (): ConvertParametersHook => { newToExtension = availableTargets.length === 1 ? availableTargets[0] : ''; } - return { + const newState = { ...prev, isSmartDetection: false, - smartDetectionType: 'none', + smartDetectionType: 'none' as const, fromExtension: fromExt, toExtension: newToExtension }; + + // Only update if something actually changed + if ( + prev.isSmartDetection === newState.isSmartDetection && + prev.smartDetectionType === newState.smartDetectionType && + prev.fromExtension === newState.fromExtension && + prev.toExtension === newState.toExtension + ) { + return prev; // Return the same object to prevent re-render + } + + return newState; }); return; } @@ -262,13 +284,25 @@ export const useConvertParameters = (): ConvertParametersHook => { newToExtension = availableTargets.length === 1 ? availableTargets[0] : ''; } - return { + const newState = { ...prev, isSmartDetection: false, - smartDetectionType: 'none', + smartDetectionType: 'none' as const, fromExtension: fromExt, toExtension: newToExtension }; + + // Only update if something actually changed + if ( + prev.isSmartDetection === newState.isSmartDetection && + prev.smartDetectionType === newState.smartDetectionType && + prev.fromExtension === newState.fromExtension && + prev.toExtension === newState.toExtension + ) { + return prev; // Return the same object to prevent re-render + } + + return newState; }); } else { // Mixed file types @@ -277,34 +311,64 @@ export const useConvertParameters = (): ConvertParametersHook => { if (allImages) { // All files are images - use image-to-pdf conversion - baseHook.setParameters(prev => ({ - ...prev, - isSmartDetection: true, - smartDetectionType: 'images', - fromExtension: 'image', - toExtension: 'pdf' - })); + baseHook.setParameters(prev => { + // Only update if something actually changed + if (prev.isSmartDetection === true && + prev.smartDetectionType === 'images' && + prev.fromExtension === 'image' && + prev.toExtension === 'pdf') { + return prev; // No change needed + } + + return { + ...prev, + isSmartDetection: true, + smartDetectionType: 'images', + fromExtension: 'image', + toExtension: 'pdf' + }; + }); } else if (allWeb) { // All files are web files - use html-to-pdf conversion - baseHook.setParameters(prev => ({ - ...prev, - isSmartDetection: true, - smartDetectionType: 'web', - fromExtension: 'html', - toExtension: 'pdf' - })); + baseHook.setParameters(prev => { + // Only update if something actually changed + if (prev.isSmartDetection === true && + prev.smartDetectionType === 'web' && + prev.fromExtension === 'html' && + prev.toExtension === 'pdf') { + return prev; // No change needed + } + + return { + ...prev, + isSmartDetection: true, + smartDetectionType: 'web', + fromExtension: 'html', + toExtension: 'pdf' + }; + }); } else { // Mixed non-image types - use file-to-pdf conversion - baseHook.setParameters(prev => ({ - ...prev, - isSmartDetection: true, - smartDetectionType: 'mixed', - fromExtension: 'any', - toExtension: 'pdf' - })); + baseHook.setParameters(prev => { + // Only update if something actually changed + if (prev.isSmartDetection === true && + prev.smartDetectionType === 'mixed' && + prev.fromExtension === 'any' && + prev.toExtension === 'pdf') { + return prev; // No change needed + } + + return { + ...prev, + isSmartDetection: true, + smartDetectionType: 'mixed', + fromExtension: 'any', + toExtension: 'pdf' + }; + }); } } - }; + }, [baseHook.setParameters]); return { ...baseHook, diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index fe6eeed5c..022789f6c 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -1,6 +1,6 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; -import { useFileActions, useToolFileSelection } from "../contexts/FileContext"; +import { useFileActions, useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { ToolWorkflowProvider, useToolWorkflow } from "../contexts/ToolWorkflowContext"; import { Group } from "@mantine/core"; @@ -22,7 +22,7 @@ function HomePageContent() { const { quickAccessRef } = sidebarRefs; - const { setMaxFiles, setIsToolMode, setSelectedFiles } = useToolFileSelection(); + const { setSelectedFiles } = useFileSelection(); const { selectedTool, selectedToolKey } = useToolWorkflow(); @@ -38,17 +38,7 @@ function HomePageContent() { ogUrl: selectedTool ? `${baseUrl}${window.location.pathname}` : baseUrl }); - // Update file selection context when tool changes - useEffect(() => { - if (selectedTool) { - setMaxFiles(selectedTool.maxFiles ?? -1); - setIsToolMode(true); - } else { - setMaxFiles(-1); - setIsToolMode(false); - // Don't clear selections when exiting tool mode - preserve selections for file/page editor - } - }, [selectedTool]); // Remove action dependencies to prevent loops + // Note: File selection limits are now handled directly by individual tools return ( { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const [collapsedPermissions, setCollapsedPermissions] = useState(true); diff --git a/frontend/src/tools/AddWatermark.tsx b/frontend/src/tools/AddWatermark.tsx index 09595b02e..1e36a3820 100644 --- a/frontend/src/tools/AddWatermark.tsx +++ b/frontend/src/tools/AddWatermark.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -26,7 +26,7 @@ import { BaseToolProps } from "../types/tool"; const AddWatermark = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const [collapsedType, setCollapsedType] = useState(false); const [collapsedStyle, setCollapsedStyle] = useState(true); diff --git a/frontend/src/tools/ChangePermissions.tsx b/frontend/src/tools/ChangePermissions.tsx index 2f91a341a..254dd4d2f 100644 --- a/frontend/src/tools/ChangePermissions.tsx +++ b/frontend/src/tools/ChangePermissions.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -16,7 +16,7 @@ import { BaseToolProps } from "../types/tool"; const ChangePermissions = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const changePermissionsParams = useChangePermissionsParameters(); const changePermissionsOperation = useChangePermissionsOperation(); diff --git a/frontend/src/tools/Compress.tsx b/frontend/src/tools/Compress.tsx index 53a4938dd..ea3fdf977 100644 --- a/frontend/src/tools/Compress.tsx +++ b/frontend/src/tools/Compress.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -16,7 +16,7 @@ import { useCompressTips } from "../components/tooltips/useCompressTips"; const Compress = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const compressParams = useCompressParameters(); const compressOperation = useCompressOperation(); diff --git a/frontend/src/tools/Convert.tsx b/frontend/src/tools/Convert.tsx index f0144a062..e2220f9ce 100644 --- a/frontend/src/tools/Convert.tsx +++ b/frontend/src/tools/Convert.tsx @@ -1,8 +1,7 @@ import React, { useEffect, useRef } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useFileState } from "../contexts/FileContext"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileState, useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -18,7 +17,7 @@ const Convert = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { selectors } = useFileState(); const { actions } = useNavigationActions(); const activeFiles = selectors.getFiles(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const scrollContainerRef = useRef(null); const convertParams = useConvertParameters(); @@ -49,7 +48,7 @@ const Convert = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { convertParams.resetParameters(); } } - }, [selectedFiles, activeFiles]); + }, [selectedFiles, activeFiles, convertParams.analyzeFileTypes, convertParams.resetParameters]); useEffect(() => { // Only clear results if we're not currently processing and parameters changed diff --git a/frontend/src/tools/OCR.tsx b/frontend/src/tools/OCR.tsx index bf652ba93..7f918759e 100644 --- a/frontend/src/tools/OCR.tsx +++ b/frontend/src/tools/OCR.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -17,7 +17,7 @@ import { useOCRTips } from "../components/tooltips/useOCRTips"; const OCR = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const ocrParams = useOCRParameters(); const ocrOperation = useOCROperation(); diff --git a/frontend/src/tools/RemoveCertificateSign.tsx b/frontend/src/tools/RemoveCertificateSign.tsx index 81bf8fa7a..0e08e117c 100644 --- a/frontend/src/tools/RemoveCertificateSign.tsx +++ b/frontend/src/tools/RemoveCertificateSign.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; import { useFileContext } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; -import { useToolFileSelection } from "../contexts/file/fileHooks"; +import { useFileSelection } from "../contexts/file/fileHooks"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const RemoveCertificateSign = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const removeCertificateSignParams = useRemoveCertificateSignParameters(); const removeCertificateSignOperation = useRemoveCertificateSignOperation(); diff --git a/frontend/src/tools/RemovePassword.tsx b/frontend/src/tools/RemovePassword.tsx index 9f214735b..4b4d1f8d6 100644 --- a/frontend/src/tools/RemovePassword.tsx +++ b/frontend/src/tools/RemovePassword.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -16,7 +16,7 @@ import { BaseToolProps } from "../types/tool"; const RemovePassword = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const removePasswordParams = useRemovePasswordParameters(); const removePasswordOperation = useRemovePasswordOperation(); diff --git a/frontend/src/tools/Repair.tsx b/frontend/src/tools/Repair.tsx index 0d1fc6f0c..8cb061085 100644 --- a/frontend/src/tools/Repair.tsx +++ b/frontend/src/tools/Repair.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; import { useFileContext } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; -import { useToolFileSelection } from "../contexts/file/fileHooks"; +import { useFileSelection } from "../contexts/file/fileHooks"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const Repair = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const repairParams = useRepairParameters(); const repairOperation = useRepairOperation(); diff --git a/frontend/src/tools/Sanitize.tsx b/frontend/src/tools/Sanitize.tsx index 108bd737b..1d12d1bee 100644 --- a/frontend/src/tools/Sanitize.tsx +++ b/frontend/src/tools/Sanitize.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const Sanitize = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const { actions } = useNavigationActions(); const sanitizeParams = useSanitizeParameters(); diff --git a/frontend/src/tools/SingleLargePage.tsx b/frontend/src/tools/SingleLargePage.tsx index 8c8530364..7d268d11c 100644 --- a/frontend/src/tools/SingleLargePage.tsx +++ b/frontend/src/tools/SingleLargePage.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; import { useFileContext } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; -import { useToolFileSelection } from "../contexts/file/fileHooks"; +import { useFileSelection } from "../contexts/file/fileHooks"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const SingleLargePage = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const singleLargePageParams = useSingleLargePageParameters(); const singleLargePageOperation = useSingleLargePageOperation(); diff --git a/frontend/src/tools/Split.tsx b/frontend/src/tools/Split.tsx index 6bccda35c..18997e6a6 100644 --- a/frontend/src/tools/Split.tsx +++ b/frontend/src/tools/Split.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; -import { useToolFileSelection } from "../contexts/FileContext"; +import { useFileSelection } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const Split = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const splitParams = useSplitParameters(); const splitOperation = useSplitOperation(); diff --git a/frontend/src/tools/UnlockPdfForms.tsx b/frontend/src/tools/UnlockPdfForms.tsx index c34806394..a169c8e58 100644 --- a/frontend/src/tools/UnlockPdfForms.tsx +++ b/frontend/src/tools/UnlockPdfForms.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import { useEndpointEnabled } from "../hooks/useEndpointConfig"; import { useFileContext } from "../contexts/FileContext"; import { useNavigationActions } from "../contexts/NavigationContext"; -import { useToolFileSelection } from "../contexts/file/fileHooks"; +import { useFileSelection } from "../contexts/file/fileHooks"; import { createToolFlow } from "../components/tools/shared/createToolFlow"; @@ -14,7 +14,7 @@ import { BaseToolProps } from "../types/tool"; const UnlockPdfForms = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); const { actions } = useNavigationActions(); - const { selectedFiles } = useToolFileSelection(); + const { selectedFiles } = useFileSelection(); const unlockPdfFormsParams = useUnlockPdfFormsParameters(); const unlockPdfFormsOperation = useUnlockPdfFormsOperation();