diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -38,6 +38,7 @@ import InputStateContainer from './input/input-state-container.react'; import LoadingIndicator from './loading-indicator.react'; import { MenuProvider } from './menu-provider.react'; +import UpdateModalHandler from './modals/update-modal.react'; import { updateNavInfoActionType } from './redux/action-types'; import DeviceIDUpdater from './redux/device-id-updater'; import DisconnectedBar from './redux/disconnected-bar'; @@ -210,6 +211,7 @@
+
void, +}; +function UpdateModal(props: Props): React.Node { + const { title, text, confirmText, onConfirm } = props; + + const { popModal } = useModalContext(); + + return ( + +
+

{text}

+
+ + +
+
+
+ ); +} + +function UpdateModalHandler(): React.Node { + const { pushModal, popModal } = useModalContext(); + + // This modal is only for the update from the first version (0.0.1) + // to the self-updating version + React.useEffect(() => { + if (electron === null || electron.version !== undefined) { + return; + } + + pushModal( + { + window.open( + 'https://electron-update.commtechnologies.org/download', + '_blank', + 'noopener noreferrer', + ); + popModal(); + }} + />, + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + React.useEffect( + () => + electron?.onNewVersionAvailable?.(version => { + pushModal( + electron?.updateToNewVersion?.()} + />, + ); + }), + [pushModal], + ); + + return null; +} + +export default UpdateModalHandler;