2018-07-28 09:47:45 +02:00
|
|
|
// @flow
|
2021-02-01 23:59:34 +01:00
|
|
|
import React, { useState } from 'react';
|
2019-03-05 05:46:57 +01:00
|
|
|
// @if TARGET='app'
|
2018-04-17 00:51:35 +02:00
|
|
|
import { ipcRenderer } from 'electron';
|
2019-03-05 05:46:57 +01:00
|
|
|
// @endif
|
2018-02-24 01:24:00 +01:00
|
|
|
import { Modal } from 'modal/modal';
|
2021-02-01 23:59:34 +01:00
|
|
|
import LastReleaseChanges from 'component/lastReleaseChanges';
|
2017-12-08 11:08:50 +01:00
|
|
|
|
2018-07-28 09:47:45 +02:00
|
|
|
type Props = {
|
2022-06-29 01:00:24 +02:00
|
|
|
closeModal: (any) => any,
|
2018-07-28 09:47:45 +02:00
|
|
|
declineAutoUpdate: () => any,
|
2022-06-29 01:00:24 +02:00
|
|
|
errorWhileUpdating: boolean,
|
2018-07-28 09:47:45 +02:00
|
|
|
};
|
|
|
|
|
2021-02-01 23:59:34 +01:00
|
|
|
const ModalAutoUpdateDownloaded = (props: Props) => {
|
2022-06-29 01:00:24 +02:00
|
|
|
const { closeModal, declineAutoUpdate, errorWhileUpdating } = props;
|
2021-02-01 23:59:34 +01:00
|
|
|
const [disabled, setDisabled] = useState(false);
|
2022-06-29 01:00:24 +02:00
|
|
|
const isDownloading = disabled && !errorWhileUpdating;
|
2018-07-28 09:47:45 +02:00
|
|
|
|
2021-02-01 23:59:34 +01:00
|
|
|
const handleConfirm = () => {
|
|
|
|
setDisabled(true);
|
|
|
|
ipcRenderer.send('autoUpdateAccepted');
|
|
|
|
};
|
2018-07-28 09:47:45 +02:00
|
|
|
|
2021-02-01 23:59:34 +01:00
|
|
|
const handleAbort = () => {
|
|
|
|
declineAutoUpdate();
|
|
|
|
closeModal();
|
|
|
|
};
|
2017-12-22 07:42:04 +01:00
|
|
|
|
2021-02-01 23:59:34 +01:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
isOpen
|
|
|
|
type="confirm"
|
|
|
|
contentLabel={__('Upgrade Downloaded')}
|
|
|
|
title={__('LBRY leveled up')}
|
2022-06-29 01:00:24 +02:00
|
|
|
confirmButtonLabel={isDownloading ? __('Downloading...') : __('Upgrade Now')}
|
2021-02-01 23:59:34 +01:00
|
|
|
abortButtonLabel={__('Not Now')}
|
2022-06-29 01:00:24 +02:00
|
|
|
confirmButtonDisabled={isDownloading}
|
2021-02-01 23:59:34 +01:00
|
|
|
onConfirmed={handleConfirm}
|
|
|
|
onAborted={handleAbort}
|
|
|
|
>
|
|
|
|
<LastReleaseChanges />
|
2022-06-29 01:33:49 +02:00
|
|
|
{errorWhileUpdating && <p>{__('There was an error while updating. Please try again.')}</p>}
|
2021-02-01 23:59:34 +01:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
2017-12-08 11:08:50 +01:00
|
|
|
|
|
|
|
export default ModalAutoUpdateDownloaded;
|