lbry-desktop/ui/modal/modalAutoUpdateDownloaded/view.jsx
Franco Montenegro f065218ff4
Prevent .deb packages from being opened with archive manager. (#7502)
* Prevent .deb packages from being opened with archive manager.

* Allow to properly cancel download upgrade and prevent multiple downloads.

* Fix missing app-update.yml file for .deb builds.

* Small fix for allowPrerelease prop in autoUpdater.

* Use release/tags endpoint to get the release details.

* Handle error case for auto updater.

* Make install now button display the upgrade modal.

* Use GitHub as provider for manual update url.

* Small fixes in updater.

* Fix small lint errors.

* Properly handle auto download on/off.
2022-07-07 16:48:42 -04:00

53 lines
1.6 KiB
JavaScript

// @flow
import React, { useState, useEffect } 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,
isDownloading: boolean,
isUpdateAvailable: boolean,
};
const ModalAutoUpdateDownloaded = (props: Props) => {
const { closeModal, declineAutoUpdate, errorWhileUpdating, isDownloading, isUpdateAvailable } = props;
const [waitingForAutoUpdateResponse, setWaitingForAutoUpdateResponse] = useState(false);
const handleConfirm = () => {
setWaitingForAutoUpdateResponse(true);
ipcRenderer.send('autoUpdateAccepted');
};
const handleAbort = () => {
declineAutoUpdate();
closeModal();
};
useEffect(() => {
setWaitingForAutoUpdateResponse(false);
}, [errorWhileUpdating, isDownloading, isUpdateAvailable]);
return (
<Modal
isOpen
type="confirm"
contentLabel={__('Upgrade Downloaded')}
title={__('LBRY leveled up')}
confirmButtonLabel={isDownloading ? __('Downloading...') : __('Upgrade Now')}
abortButtonLabel={isDownloading ? __('Keep browsing') : __('Not Now')}
confirmButtonDisabled={!isUpdateAvailable || isDownloading || waitingForAutoUpdateResponse}
onConfirmed={handleConfirm}
onAborted={handleAbort}
>
<LastReleaseChanges />
{errorWhileUpdating && <p>{__('There was an error while updating. Please try again.')}</p>}
</Modal>
);
};
export default ModalAutoUpdateDownloaded;