diff --git a/ui/index.jsx b/ui/index.jsx index 18eee1e56..e75024174 100644 --- a/ui/index.jsx +++ b/ui/index.jsx @@ -20,6 +20,7 @@ import { doHideModal, doToggle3PAnalytics, doUpdateDownloadProgress, + doNotifyUpdateAvailable, } from 'redux/actions/app'; import { isURIValid } from 'util/lbryURI'; import { setSearchApi } from 'redux/actions/search'; @@ -129,14 +130,8 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => { handleError(); }); -autoUpdater.on('update-available', ({ version }) => { - app.store.dispatch({ - type: ACTIONS.CHECK_UPGRADE_SUCCESS, - data: { - upgradeAvailable: true, - remoteVersion: version, - }, - }); +autoUpdater.on('update-available', (e) => { + app.store.dispatch(doNotifyUpdateAvailable(e)); }); ipcRenderer.on('download-progress-update', (e, p) => { diff --git a/ui/modal/modalUpgrade/index.js b/ui/modal/modalUpgrade/index.js index f1b581217..c99909156 100644 --- a/ui/modal/modalUpgrade/index.js +++ b/ui/modal/modalUpgrade/index.js @@ -1,10 +1,13 @@ import { connect } from 'react-redux'; +import { selectRemoteVersion } from 'redux/selectors/app'; import { doDownloadUpgrade, doSkipUpgrade, doHideModal } from 'redux/actions/app'; import ModalUpgrade from './view'; -const select = () => ({}); +const select = (state) => ({ + releaseVersion: selectRemoteVersion(state), +}); -const perform = dispatch => ({ +const perform = (dispatch) => ({ downloadUpgrade: () => dispatch(doDownloadUpgrade()), skipUpgrade: () => { dispatch(doHideModal()); @@ -12,7 +15,4 @@ const perform = dispatch => ({ }, }); -export default connect( - select, - perform -)(ModalUpgrade); +export default connect(select, perform)(ModalUpgrade); diff --git a/ui/modal/modalUpgrade/view.jsx b/ui/modal/modalUpgrade/view.jsx index 0af7b5665..0c85a861e 100644 --- a/ui/modal/modalUpgrade/view.jsx +++ b/ui/modal/modalUpgrade/view.jsx @@ -8,11 +8,12 @@ const IS_MAC = navigator.userAgent.indexOf('Mac OS X') !== -1; type Props = { downloadUpgrade: () => void, skipUpgrade: () => void, + releaseVersion: string, }; class ModalUpgrade extends React.PureComponent { render() { - const { downloadUpgrade, skipUpgrade } = this.props; + const { downloadUpgrade, skipUpgrade, releaseVersion } = this.props; return ( { onConfirmed={downloadUpgrade} onAborted={skipUpgrade} > -

- {__('An updated version of LBRY is now available.')}{' '} - {__('Your version is out of date and may be unreliable or insecure.')} -

+ {__('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseVersion })}
); diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js index 69a40a18a..33b1a3e9c 100644 --- a/ui/redux/actions/app.js +++ b/ui/redux/actions/app.js @@ -18,7 +18,6 @@ import { Lbryio } from 'lbryinc'; import { selectFollowedTagsList } from 'redux/selectors/tags'; import { doToast, doError, doNotificationList } from 'redux/actions/notifications'; -import Native from 'native'; import { doFetchDaemonSettings, doSetAutoLaunch, @@ -183,45 +182,50 @@ export function doCheckUpgradeAvailable() { type: ACTIONS.CHECK_UPGRADE_START, }); - if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) { - // On Windows, Mac, and AppImage, updates happen silently through - // electron-updater. - const autoUpdateDeclined = selectAutoUpdateDeclined(state); - const disableAutoUpdate = selectDisableAutoUpdates(state); + const autoUpdateSupported = ['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE; - if (autoUpdateDeclined || isDev) { - return; - } + const autoUpdateDeclined = selectAutoUpdateDeclined(state); - ipcRenderer.send('check-for-updates', !disableAutoUpdate); + // If auto update isn't supported (Linux using .deb packages) + // don't perform any download, just get the upgrade info + // (release notes and version) + const disableAutoUpdate = !autoUpdateSupported || selectDisableAutoUpdates(state); + + if (autoUpdateDeclined || isDev) { return; } - const success = ({ remoteVersion, upgradeAvailable }) => { - dispatch({ - type: ACTIONS.CHECK_UPGRADE_SUCCESS, - data: { - upgradeAvailable, - remoteVersion, - }, - }); + ipcRenderer.send('check-for-updates', !disableAutoUpdate); + }; +} - if ( - upgradeAvailable && - !selectModal(state) && - (!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state)) - ) { - dispatch(doOpenModal(MODALS.UPGRADE)); - } - }; +export function doNotifyUpdateAvailable(e) { + return (dispatch, getState) => { + const remoteVersion = e.releaseName || e.version; - const fail = () => { - dispatch({ - type: ACTIONS.CHECK_UPGRADE_FAIL, - }); - }; + const state = getState(); + const noModalBeingDisplayed = !selectModal(state); + const isUpgradeSkipped = selectIsUpgradeSkipped(state); + const isRemoveVersionDiff = remoteVersion !== selectRemoteVersion(state); - Native.getAppVersionInfo().then(success, fail); + dispatch({ + type: ACTIONS.CHECK_UPGRADE_SUCCESS, + data: { + upgradeAvailable: true, + remoteVersion, + releaseNotes: e.releaseNotes, + }, + }); + + const autoUpdateSupported = ['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE; + + if (autoUpdateSupported) { + return; + } + + if (noModalBeingDisplayed && !isUpgradeSkipped && isRemoveVersionDiff) { + dispatch(doOpenModal(MODALS.UPGRADE)); + } }; }