Skip to content

refactor: fft module improvement#144

Open
ihasp wants to merge 17 commits into
BiometricsUBB:masterfrom
ihasp:master
Open

refactor: fft module improvement#144
ihasp wants to merge 17 commits into
BiometricsUBB:masterfrom
ihasp:master

Conversation

@ihasp
Copy link
Copy Markdown

@ihasp ihasp commented Apr 28, 2026

Fft module improvement

1. Refactor of edit-window.tsx

  • Huge monolithic component refactored to use hooks instead:

useImageIO - Handles file loading, saving, Tauri filesystem plugins, and filename generation
useImagePanZoom - Handles math, state and mouse event listeners
useElementSync - Keeps the ResizedObserver that keeps overlay canvases synced to image's dimensions

  • Exctracted UI Components:

SidebarTools: Handles the Save button and image metadata.
SidebarAdjustments: Handles the brightness and contrast sliders.
SidebarFFT: Handles the FFT tools (brush size, shape, mode toggles, and apply/clear)

2. New way of working on the FFT

  • Instead of checking the fingerprint result via transparency silder, new pane shows up:

Left one is the FFT canvas on which you can draw, and the Right one with live updating effect
Added new brush and 'rubber' to remove the 'drawing'

Comment on lines +45 to +46
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dependencies: any[] = [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

can we type this up somehow?

Comment on lines +9 to +10
// eslint-disable-next-line @typescript-eslint/no-explicit-any
t: any,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type

Comment on lines +62 to +64
fft.interactionMode !== "pan"
? "bg-background shadow-sm text-foreground"
: "text-muted-foreground hover:bg-secondary/80 hover:text-secondary-foreground"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fft.interactionMode !== "pan"
? "bg-background shadow-sm text-foreground"
: "text-muted-foreground hover:bg-secondary/80 hover:text-secondary-foreground"
fft.interactionMode === "draw"
? "bg-background shadow-sm text-foreground"
: "text-muted-foreground hover:bg-secondary/80 hover:text-secondary-foreground"

unless, of course, this is the intended effect in erease mode.

Comment on lines +151 to +157
let unlistenPromise: Promise<() => void> | null = null;
setupListener().then(unlisten => {
unlistenPromise = Promise.resolve(unlisten);
});
return () => {
unlistenPromise?.then(fn => fn());
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

race condition - if the component is unmounted befare setupListener finishes, unlinstenPromise remains null and the listener is never removed.

Comment on lines +137 to +145
rafId = requestAnimationFrame(() => {
doRedrawOverlay();
updateLivePreview();

nestedRafId = requestAnimationFrame(() => {
doRedrawOverlay();
updateLivePreview();
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need 2x requestAnimationFrame? shall we add a comment?

return <EditWindowContent />;
}

export function EditWindowWithProps({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants