From 0b156494b5be5f45b571db939c77407f6acfbb33 Mon Sep 17 00:00:00 2001 From: FLorial Jean Baptiste Date: Tue, 11 Feb 2025 15:31:48 +0100 Subject: [PATCH] Cleanup/improve Connection Lost Dialog --- ui/src/containers/ConnectionLostDialog.jsx | 104 +++++---------------- 1 file changed, 21 insertions(+), 83 deletions(-) diff --git a/ui/src/containers/ConnectionLostDialog.jsx b/ui/src/containers/ConnectionLostDialog.jsx index 11785f6b6..70e23f070 100644 --- a/ui/src/containers/ConnectionLostDialog.jsx +++ b/ui/src/containers/ConnectionLostDialog.jsx @@ -1,88 +1,26 @@ -/* eslint-disable react/jsx-handler-names */ -/* eslint-disable react/no-string-refs */ import React from 'react'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; +import { useSelector } from 'react-redux'; import { Modal, Button } from 'react-bootstrap'; -import { showConnectionLostDialog } from '../actions/general'; -export class ConnectionLostDialog extends React.Component { - constructor(props) { - super(props); - this.accept = this.accept.bind(this); - this.reject = this.reject.bind(this); - this.intervalCb = this.intervalCb.bind(this); - this.seconds = 60; - this.timerid = undefined; - } - - intervalCb() { - this.seconds--; - - if (this.refs.countdown) { - this.refs.countdown.innerHTML = this.seconds; - } - - if (this.seconds < 1) { - this.seconds = 0; - this.accept(); - } - } - - accept() { - this.forceUpdate(); - } - - reject() { - this.props.hide(); - } - - render() { - this.seconds = 60; - - if (this.timerid) { - clearInterval(this.timerid); - } - - this.timerid = setInterval(this.intervalCb, 1000); - setTimeout(() => { - clearInterval(this.timerid); - }, this.seconds * 1000); - - return ( - - - Connection lost - - - Ooops ! There seems to be a problem with the internet connection, the - connection to the server was lost. Trying to reconnect in{' '} - {this.seconds} s - - - - - - ); - } -} - -function mapStateToProps(state) { - return { - show: state.general.showConnectionLostDialog, - }; -} - -function mapDispatchToProps(dispatch) { - return { - hide: bindActionCreators( - showConnectionLostDialog.bind(null, false), - dispatch, - ), - }; +export function ConnectionLostDialog() { + const show = useSelector((state) => state.general.showConnectionLostDialog); + + return ( + + + Connection lost + + + Trying to reconnect now... +
+ If the issue persists, please check your Internet connection or reload + the page. +
+ + + +
+ ); } -export default connect( - mapStateToProps, - mapDispatchToProps, -)(ConnectionLostDialog); +export default ConnectionLostDialog;