diff --git a/web/modals/update-modal.react.js b/web/modals/update-modal.react.js index eea37d027..61d60844c 100644 --- a/web/modals/update-modal.react.js +++ b/web/modals/update-modal.react.js @@ -1,92 +1,98 @@ // @flow import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; import Modal from './modal.react.js'; import css from './update-modal.css'; import Button from '../components/button.react.js'; import electron from '../electron.js'; type Props = { +title: string, +text: string, +confirmText: string, +onConfirm: () => 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 => { + // On these versions we want to update immediately because there's + // an issue if the user decides to update 10min after showing the modal + if (electron?.version === '1.0.0' || electron?.version === '2.0.0') { + electron?.updateToNewVersion?.(); + } + pushModal( electron?.updateToNewVersion?.()} />, ); }), [pushModal], ); return null; } export default UpdateModalHandler;