diff --git a/electron/renderer/src/components/LoadingSpinner.css b/electron/renderer/src/components/LoadingSpinner.css index 6914af6bc84..5c99b929d4a 100644 --- a/electron/renderer/src/components/LoadingSpinner.css +++ b/electron/renderer/src/components/LoadingSpinner.css @@ -19,6 +19,7 @@ .loading-spinner-wrapper { height: 100vh; + display: flex; position: absolute; width: 100%; z-index: 2; diff --git a/electron/renderer/src/components/LoadingSpinner.jsx b/electron/renderer/src/components/LoadingSpinner.jsx index f3c5595d01c..38a002f8732 100644 --- a/electron/renderer/src/components/LoadingSpinner.jsx +++ b/electron/renderer/src/components/LoadingSpinner.jsx @@ -22,8 +22,11 @@ import {FlexBox, Loading, COLOR} from '@wireapp/react-ui-kit'; import './LoadingSpinner.css'; +const TRANSITION_GRACE_PERIOD_MS = 500; + const LoadingSpinner = ({visible, webviewRef}) => { const [isLoading, setIsLoading] = useState(true); + const [isFinished, setIsFinished] = useState(false); useEffect(() => { const webview = webviewRef.current; @@ -37,13 +40,30 @@ const LoadingSpinner = ({visible, webviewRef}) => { } }); + useEffect(() => { + if (!isLoading) { + let timeout = setTimeout(() => { + timeout = null; + setIsFinished(true); + }, TRANSITION_GRACE_PERIOD_MS); + + return () => { + if (timeout !== null) { + clearTimeout(timeout); + } + }; + } + }, [isLoading]); + + if (!visible || isFinished) { + return null; + } return (