mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Reset rotation when starting again
This commit is contained in:
parent
49e64866d1
commit
7caa91567f
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useCallback } from 'react';
|
import { useEffect, useCallback, useRef } from 'react';
|
||||||
import { useFileSelection } from '../../../contexts/FileContext';
|
import { useFileSelection } from '../../../contexts/FileContext';
|
||||||
import { useEndpointEnabled } from '../../useEndpointConfig';
|
import { useEndpointEnabled } from '../../useEndpointConfig';
|
||||||
import { BaseToolProps } from '../../../types/tool';
|
import { BaseToolProps } from '../../../types/tool';
|
||||||
@ -45,6 +45,7 @@ export function useBaseTool<TParams, TParamsHook extends BaseParametersHook<TPar
|
|||||||
|
|
||||||
// File selection
|
// File selection
|
||||||
const { selectedFiles } = useFileSelection();
|
const { selectedFiles } = useFileSelection();
|
||||||
|
const previousFileCount = useRef(selectedFiles.length);
|
||||||
|
|
||||||
// Tool-specific hooks
|
// Tool-specific hooks
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@ -67,6 +68,18 @@ export function useBaseTool<TParams, TParamsHook extends BaseParametersHook<TPar
|
|||||||
}
|
}
|
||||||
}, [selectedFiles.length]);
|
}, [selectedFiles.length]);
|
||||||
|
|
||||||
|
// Reset parameters when transitioning from 0 files to at least 1 file
|
||||||
|
useEffect(() => {
|
||||||
|
const currentFileCount = selectedFiles.length;
|
||||||
|
const prevFileCount = previousFileCount.current;
|
||||||
|
|
||||||
|
if (prevFileCount === 0 && currentFileCount > 0) {
|
||||||
|
params.resetParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousFileCount.current = currentFileCount;
|
||||||
|
}, [selectedFiles.length]);
|
||||||
|
|
||||||
// Standard handlers
|
// Standard handlers
|
||||||
const handleExecute = useCallback(async () => {
|
const handleExecute = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user