mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: reset processed state and tool-specific stores on tool navigation
This commit is contained in:
@@ -27,8 +27,14 @@ import { useMobile } from "@/hooks/use-mobile";
|
||||
import { formatFileSize } from "@/lib/download";
|
||||
import { ICON_MAP } from "@/lib/icon-map";
|
||||
import { getToolRegistryEntry } from "@/lib/tool-registry";
|
||||
import { useBase64Store } from "@/stores/base64-store";
|
||||
import { useCollageStore } from "@/stores/collage-store";
|
||||
import { useDuplicateStore } from "@/stores/duplicate-store";
|
||||
import { useFeaturesStore } from "@/stores/features-store";
|
||||
import { useFileStore } from "@/stores/file-store";
|
||||
import { usePdfToImageStore } from "@/stores/pdf-to-image-store";
|
||||
import { useQrStore } from "@/stores/qr-store";
|
||||
import { useSplitStore } from "@/stores/split-store";
|
||||
|
||||
/** Formats that browsers can render in <img> tags. */
|
||||
const BROWSER_PREVIEWABLE_EXTS = new Set([
|
||||
@@ -202,11 +208,30 @@ export function ToolPage() {
|
||||
// Center of the painted mask as a 0-100 percentage — used to init the slider at the right spot
|
||||
const [eraserSliderInitPos, setEraserSliderInitPos] = useState<number | null>(null);
|
||||
|
||||
// Reset crop state when the image changes
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: toolId triggers intentional reset on tool navigation
|
||||
useEffect(() => {
|
||||
useFileStore.getState().undoProcessing();
|
||||
|
||||
useBase64Store.getState().reset();
|
||||
useCollageStore.getState().reset();
|
||||
useDuplicateStore.getState().reset();
|
||||
usePdfToImageStore.getState().reset();
|
||||
useQrStore.getState().reset();
|
||||
useSplitStore.getState().reset();
|
||||
|
||||
setPreviewTransform(null);
|
||||
setPreviewFilter("");
|
||||
setImageWrapperStyle(null);
|
||||
setBgPreview(null);
|
||||
setCropCrop({ unit: "%", x: 0, y: 0, width: 100, height: 100 });
|
||||
setCropAspect(undefined);
|
||||
setCropShowGrid(true);
|
||||
setCropImgDimensions(null);
|
||||
}, []);
|
||||
setEraserHasStrokes(false);
|
||||
setEraserBrushSize(30);
|
||||
setEraserSliderInitPos(null);
|
||||
setMobileSettingsOpen(true);
|
||||
}, [toolId]);
|
||||
|
||||
const handleFiles = useCallback(
|
||||
(newFiles: File[]) => {
|
||||
|
||||
Reference in New Issue
Block a user