From 6bc81cf90f1c66271cc8a7a78a5e7453e2560bec Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 6 Sep 2026 17:10:48 +0100 Subject: [PATCH] Enhance ApiServerContext with Improved Reconnection Handling - Added loading state indication during reconnection attempts in the modal. - Adjusted modal dimensions and styles based on the reconnection status for better user experience. - Streamlined the display logic for connection lost messages and reconnection progress, improving clarity and responsiveness. --- .../Dashboard/context/ApiServerContext.jsx | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/components/Dashboard/context/ApiServerContext.jsx b/src/components/Dashboard/context/ApiServerContext.jsx index b7bd183a..a6ec56c4 100644 --- a/src/components/Dashboard/context/ApiServerContext.jsx +++ b/src/components/Dashboard/context/ApiServerContext.jsx @@ -12,13 +12,14 @@ import { message, Modal, Space, Button, Typography, Flex } from 'antd' import PropTypes from 'prop-types' import { AuthContext } from './AuthContext' import { useLocation, useNavigate } from 'react-router-dom' - +import { LoadingOutlined } from '@ant-design/icons' import axios from 'axios' import ExclamationOctagonIcon from '../../Icons/ExclamationOctagonIcon' import ReloadIcon from '../../Icons/ReloadIcon' import LockIcon from '../../Icons/LockIcon' import config from '../../../config' import loglevel from 'loglevel' + import { getModelByName } from '../../../database/ObjectModels' import ProgressDisplay from '../common/ProgressDisplay' const logger = loglevel.getLogger('ApiServerContext') @@ -2920,42 +2921,59 @@ const ApiServerProvider = ({ children }) => { {children} - - Connection Lost - + !isReconnecting ? ( + + + Connection Lost + + ) : ( + false + ) } open={Boolean(token) && authenticated == true && connectionIssue} - style={{ maxWidth: 480 }} + style={{ maxWidth: !isReconnecting ? 480 : 260 }} zIndex={3000} closable={false} + height={isReconnecting ? 20 : undefined} centered + className={isReconnecting ? 'loading-modal' : undefined} maskClosable={false} getContainer={() => document.body} - footer={[ - - ]} + footer={ + !isReconnecting + ? [ + + ] + : false + } > - - - {isReconnecting - ? 'Reconnecting to the API server...' - : `Lost connection to the API server. Reconnecting in ${reconnectSecondsRemaining} second${ - reconnectSecondsRemaining === 1 ? '' : 's' - }...`} - - - + {!isReconnecting ? ( + + + {isReconnecting + ? 'Reconnecting to the API server...' + : `Lost connection to the API server. Reconnecting in ${reconnectSecondsRemaining} second${ + reconnectSecondsRemaining === 1 ? '' : 's' + }...`} + + + + ) : ( + + + Reconnecting, please wait... + + )}