feat: more tests, refactored

This commit is contained in:
2026-05-24 21:05:21 +07:00
parent e7dd9420e7
commit c1f12c7201
33 changed files with 1403 additions and 334 deletions
+1 -14
View File
@@ -32,7 +32,6 @@ type SelectedImageLayer = {
type UseFaceDetectionOptions = {
tool: EditorToolId;
selectedLayerId: string | null;
selectedImageLayer: SelectedImageLayer | null;
activeLayerStillSelected: (layerId: string) => boolean;
};
@@ -40,7 +39,6 @@ type UseFaceDetectionOptions = {
export function useFaceDetection(options: UseFaceDetectionOptions) {
const {
tool,
selectedLayerId,
selectedImageLayer,
activeLayerStillSelected,
} = options;
@@ -63,6 +61,7 @@ export function useFaceDetection(options: UseFaceDetectionOptions) {
(status: "idle" | "detecting" | "unsupported" = "idle") => {
setFaceDetections((prev) => (prev.length === 0 ? prev : []));
setFaceDetectionsLayerId((prev) => (prev === null ? prev : null));
setFacePreviews((prev) => (prev.length === 0 ? prev : []));
setFaceStatus((prev) => (prev === status ? prev : status));
},
[],
@@ -115,18 +114,6 @@ export function useFaceDetection(options: UseFaceDetectionOptions) {
tool,
]);
React.useEffect(() => {
if (tool !== "face") {
setFaceDetections([]);
setFaceDetectionsLayerId(null);
setFacePreviews([]);
return;
}
setFaceDetections([]);
setFaceDetectionsLayerId(null);
setFacePreviews([]);
}, [tool, selectedLayerId]);
React.useEffect(() => {
let canceled = false;