From c399ad45e724bf0afc31318644279897f9d5295f Mon Sep 17 00:00:00 2001
From: Maryna _Kosau <50210952+marinakosova@users.noreply.github.com>
Date: Sat, 1 Oct 2022 10:43:15 -0500
Subject: [PATCH] fix: add spinner to prevent previous capture appearance
(#827)
---
src/components/CaptureDetailDialog.js | 33 +++++++++++++++++++++------
src/components/OptimizedImage.js | 4 ++++
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/components/CaptureDetailDialog.js b/src/components/CaptureDetailDialog.js
index 28b5b81bc..0cb0dfc3b 100644
--- a/src/components/CaptureDetailDialog.js
+++ b/src/components/CaptureDetailDialog.js
@@ -11,6 +11,7 @@ import {
Drawer,
Box,
Link,
+ CircularProgress,
} from '@material-ui/core';
import Close from '@material-ui/icons/Close';
import OptimizedImage from './OptimizedImage';
@@ -82,6 +83,9 @@ const useStyles = makeStyles((theme) => ({
itemValue: {
lineHeight: 1.7,
},
+ spinner: {
+ position: 'fixed',
+ },
}));
function CaptureDetailDialog(props) {
@@ -91,6 +95,7 @@ function CaptureDetailDialog(props) {
const [snackbarLabel, setSnackbarLabel] = useState('');
const [renderCapture, setRenderCapture] = useState(null);
const [isLoading, setIsLoading] = useState(true);
+ const [isImageLoading, setIsImageLoading] = useState(true);
const classes = useStyles();
// This is causing unnecessary re-renders right now, but may be useful if we want to navigate between captures by id
@@ -139,6 +144,7 @@ function CaptureDetailDialog(props) {
if (isLoading) {
setIsLoading(false);
}
+ setIsImageLoading(true);
}, [cdContext.capture]);
useEffect(() => {
@@ -356,13 +362,26 @@ function CaptureDetailDialog(props) {
}}
maxWidth="md"
>
-
+ {isLoading ? (
+
+ ) : (
+ <>
+ {isImageLoading && (
+
+ )}
+
+ {
+ setIsImageLoading(false);
+ }}
+ />
+ >
+ )}
{
+ onImageReady && onImageReady();
+ }}
style={{
position: 'absolute',
left: 0,