Display release notes and version for Linux installations using .deb packages.

This commit is contained in:
Franco Montenegro 2022-03-01 10:53:00 -03:00 committed by jessopb
parent 64a2e908ae
commit 1f8c9fd24d
4 changed files with 48 additions and 51 deletions

View file

@ -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) => {

View file

@ -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);

View file

@ -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<Props> {
render() {
const { downloadUpgrade, skipUpgrade } = this.props;
const { downloadUpgrade, skipUpgrade, releaseVersion } = this.props;
return (
<Modal
@ -26,10 +27,7 @@ class ModalUpgrade extends React.PureComponent<Props> {
onConfirmed={downloadUpgrade}
onAborted={skipUpgrade}
>
<p>
{__('An updated version of LBRY is now available.')}{' '}
{__('Your version is out of date and may be unreliable or insecure.')}
</p>
{__('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseVersion })}
<LastReleaseChanges hideReleaseVersion />
</Modal>
);

View file

@ -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));
}
};
}