diff --git a/app/components/common/Version.tsx b/app/components/common/Version.tsx index ec4face74..54f472cfc 100644 --- a/app/components/common/Version.tsx +++ b/app/components/common/Version.tsx @@ -21,6 +21,10 @@ import { getNetworkInfo } from '../../redux/network/selectors'; import { checkUpdates as checkUpdatesIco } from '../../assets/images'; import { AppThDispatch } from '../../types'; import updaterSlice from '../../redux/updater/slice'; +import { SECOND } from '../../../shared/constants'; +import { Loader } from '../../basicComponents'; +import UpdateApplicationWarningModal from '../../screens/modal/UpdateApplicationWarningModal'; +import * as SmesherSelectors from '../../redux/smesher/selectors'; import FeedbackButton from './Feedback'; const Container = styled.div` @@ -194,6 +198,38 @@ const UpdateStatus = () => { const isDownloading = useSelector(isUpdateDownloading); const isDownloaded = useSelector(isUpdateDownloaded); const error = useSelector(getError); + const isSmeshing = useSelector(SmesherSelectors.isSmeshing); + const [ + isOpenUpdateApplicationWarningModal, + setIsOpenUpdateApplicationWarningModal, + ] = useState(false); + const [ + showUpdateApplicationLoader, + setShowUpdateApplicationLoader, + ] = useState(false); + + const handleRestartNow = () => { + setIsOpenUpdateApplicationWarningModal(false); + setShowUpdateApplicationLoader(true); + eventsService.installUpdate(); + + setTimeout(() => { + setShowUpdateApplicationLoader(false); + }, 10 * SECOND); + }; + + const handleRestart = () => { + if (isSmeshing) { + setIsOpenUpdateApplicationWarningModal(true); + } else { + handleRestartNow(); + } + }; + + const handlePostpone = () => { + setIsOpenUpdateApplicationWarningModal(false); + }; + if (!isDownloading && !isDownloaded) return null; if (progress !== null && !isDownloaded) { @@ -207,9 +243,15 @@ const UpdateStatus = () => { return ( <> Update is ready to install - eventsService.installUpdate()}> - Restart Smapp - + Restart Smapp + + {showUpdateApplicationLoader && ( + + )} ); } diff --git a/app/screens/modal/UpdateApplicationWarningModal.tsx b/app/screens/modal/UpdateApplicationWarningModal.tsx new file mode 100644 index 000000000..e7cf59c88 --- /dev/null +++ b/app/screens/modal/UpdateApplicationWarningModal.tsx @@ -0,0 +1,67 @@ +import React from 'react'; +import styled from 'styled-components'; +import Modal from '../../components/common/Modal'; +import { Button } from '../../basicComponents'; +import { smColors } from '../../vars'; + +const ButtonsWrapper = styled.div` + display: flex; + flex-direction: row; + justify-content: space-between; + margin: auto 0 15px 0; + padding-top: 30px; +`; + +const Message = styled.pre` + font-size: 14px; + line-height: 1.33em; + word-wrap: break-word; + white-space: pre-wrap; + overflow-y: auto; + margin-top: 15px; + + ul { + list-style: none; + margin-left: 10px; + } + li { + margin: 10px 0; + } + li:before { + content: '• '; + padding: 5px; + } +`; + +const UpdateApplicationWarningModal = ({ isOpen, onApprove, onCancel }) => { + if (!isOpen) return null; + + return ( + + +

+ To finalize the update, Smapp must be restarted. However, verify your + eligibility for upcoming layer rewards. Powering off the node risks + missing proposal submissions and losing the rewards. +

+
    +
  • + Click RESTART NOW to apply + the update immediately. +
  • +
  • + Click POSTPONE to delay + the update. The persistent "restart Smapp" button will + remind you about the pending update. +
  • +
+
+ +