lbry-desktop/ui/modal/modalAutoUpdateDownloaded/view.jsx
2022-06-28 20:33:49 -03:00

48 lines
1.3 KiB
JavaScript

// @flow
import React, { useState } from 'react';
// @if TARGET='app'
import { ipcRenderer } from 'electron';
// @endif
import { Modal } from 'modal/modal';
import LastReleaseChanges from 'component/lastReleaseChanges';
type Props = {
closeModal: (any) => any,
declineAutoUpdate: () => any,
errorWhileUpdating: boolean,
};
const ModalAutoUpdateDownloaded = (props: Props) => {
const { closeModal, declineAutoUpdate, errorWhileUpdating } = props;
const [disabled, setDisabled] = useState(false);
const isDownloading = disabled && !errorWhileUpdating;
const handleConfirm = () => {
setDisabled(true);
ipcRenderer.send('autoUpdateAccepted');
};
const handleAbort = () => {
declineAutoUpdate();
closeModal();
};
return (
<Modal
isOpen
type="confirm"
contentLabel={__('Upgrade Downloaded')}
title={__('LBRY leveled up')}
confirmButtonLabel={isDownloading ? __('Downloading...') : __('Upgrade Now')}
abortButtonLabel={__('Not Now')}
confirmButtonDisabled={isDownloading}
onConfirmed={handleConfirm}
onAborted={handleAbort}
>
<LastReleaseChanges />
{errorWhileUpdating && <p>{__('There was an error while updating. Please try again.')}</p>}
</Modal>
);
};
export default ModalAutoUpdateDownloaded;