From 9fbd62f2a7ee3def1c4a9a854921f389c3332370 Mon Sep 17 00:00:00 2001 From: jue-henry Date: Wed, 18 Dec 2024 13:55:45 -0800 Subject: [PATCH] fixing rendering errors --- src/features/cameras/DeleteCameraAlert.jsx | 25 ++++++++++++------- .../images}/DeleteImagesProgressBar.jsx | 23 +++++++++-------- src/features/tasks/tasksSlice.js | 2 ++ 3 files changed, 30 insertions(+), 20 deletions(-) rename src/{components => features/images}/DeleteImagesProgressBar.jsx (76%) diff --git a/src/features/cameras/DeleteCameraAlert.jsx b/src/features/cameras/DeleteCameraAlert.jsx index 1fa227d..b708c80 100644 --- a/src/features/cameras/DeleteCameraAlert.jsx +++ b/src/features/cameras/DeleteCameraAlert.jsx @@ -1,10 +1,15 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { red } from '@radix-ui/colors'; import { styled } from '../../theme/stitches.config.js'; import Button from '../../components/Button.jsx'; import { ButtonRow } from '../../components/Form.jsx'; -import { deleteCamera, fetchTask, selectDeleteCameraLoading } from '../tasks/tasksSlice.js'; +import { + clearDeleteCameraTask, + deleteCamera, + fetchTask, + selectDeleteCameraLoading, +} from '../tasks/tasksSlice.js'; import { SimpleSpinner, SpinnerOverlay } from '../../components/Spinner.jsx'; import { selectSelectedCamera } from '../projects/projectsSlice.js'; import { @@ -29,7 +34,6 @@ const BoldText = styled('span', { }); const DeleteCameraAlert = () => { - const [queuedForClose, setQueuedForClose] = useState(false); const deleteCameraLoading = useSelector(selectDeleteCameraLoading); const selectedCamera = useSelector(selectSelectedCamera); const imageCount = useSelector(selectCameraImageCount); @@ -44,13 +48,16 @@ const DeleteCameraAlert = () => { }, [imageCount, selectedCamera, dispatch]); useEffect(() => { - if (queuedForClose && !deleteCameraLoading.isLoading) - dispatch(setDeleteCameraAlertStatus(false)); - }, [deleteCameraLoading, queuedForClose]); + if (!deleteCameraLoading.isLoading) dispatch(setDeleteCameraAlertStatus(false)); + }, [deleteCameraLoading]); const handleDeleteCameraSubmit = () => { dispatch(deleteCamera({ cameraId: selectedCamera })); - setQueuedForClose(true); + }; + + const handleCancelDelete = () => { + dispatch(setDeleteCameraAlertStatus(false)); + dispatch(clearDeleteCameraTask()); }; // handle polling for task completion @@ -83,7 +90,7 @@ const DeleteCameraAlert = () => { {ASYNC_IMAGE_DELETE_BY_FILTER_LIMIT} before trying again. We apologize for the inconvenience. - @@ -95,7 +102,7 @@ const DeleteCameraAlert = () => { it, and {imagesText} will be deleted.{' '} This action cannot be undone. -