Better way of handling autoUpdate and listen for update available event to display update nag.
This commit is contained in:
parent
48c5f58a8e
commit
e1ecf87df7
6 changed files with 21 additions and 16 deletions
|
@ -320,13 +320,14 @@ ipcMain.on('upgrade', (event, installerPath) => {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('check-for-updates', () => {
|
ipcMain.on('check-for-updates', (event, autoDownload) => {
|
||||||
// Prevent downloading the same update multiple times.
|
// Prevent downloading the same update multiple times.
|
||||||
if (!keepCheckingForUpdates) {
|
if (!keepCheckingForUpdates) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
keepCheckingForUpdates = false;
|
keepCheckingForUpdates = false;
|
||||||
|
autoUpdater.autoDownload = autoDownload;
|
||||||
autoUpdater.checkForUpdates();
|
autoUpdater.checkForUpdates();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,7 @@ function App(props: Props) {
|
||||||
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
|
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
|
||||||
// const [retryingSync, setRetryingSync] = useState(false);
|
// const [retryingSync, setRetryingSync] = useState(false);
|
||||||
const [sidebarOpen] = usePersistedState('sidebar', true);
|
const [sidebarOpen] = usePersistedState('sidebar', true);
|
||||||
const showUpgradeButton =
|
const showUpgradeButton = (autoUpdateDownloaded || isUpgradeAvailable) && !upgradeNagClosed;
|
||||||
(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && !upgradeNagClosed;
|
|
||||||
// referral claiming
|
// referral claiming
|
||||||
const referredRewardAvailable = rewards && rewards.some((reward) => reward.reward_type === REWARDS.TYPE_REFEREE);
|
const referredRewardAvailable = rewards && rewards.some((reward) => reward.reward_type === REWARDS.TYPE_REFEREE);
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as remote from '@electron/remote';
|
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
|
|
||||||
const { autoUpdater } = remote.require('electron-updater');
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
setClientSetting: (boolean) => void,
|
setClientSetting: (boolean) => void,
|
||||||
disableAutoUpdates: boolean,
|
disableAutoUpdates: boolean,
|
||||||
|
@ -18,7 +15,6 @@ function SettingDisableAutoUpdates(props: Props) {
|
||||||
name="autoupdates"
|
name="autoupdates"
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
const newDisableAutoUpdates = !disableAutoUpdates;
|
const newDisableAutoUpdates = !disableAutoUpdates;
|
||||||
autoUpdater.autoDownload = !newDisableAutoUpdates;
|
|
||||||
setClientSetting(newDisableAutoUpdates);
|
setClientSetting(newDisableAutoUpdates);
|
||||||
}}
|
}}
|
||||||
checked={disableAutoUpdates}
|
checked={disableAutoUpdates}
|
||||||
|
|
16
ui/index.jsx
16
ui/index.jsx
|
@ -117,6 +117,16 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
|
||||||
handleError();
|
handleError();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
autoUpdater.on('update-available', ({ version }) => {
|
||||||
|
app.store.dispatch({
|
||||||
|
type: ACTIONS.CHECK_UPGRADE_SUCCESS,
|
||||||
|
data: {
|
||||||
|
upgradeAvailable: true,
|
||||||
|
remoteVersion: version,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ipcRenderer.on('download-progress-update', (e, p) => {
|
ipcRenderer.on('download-progress-update', (e, p) => {
|
||||||
app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100)));
|
app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100)));
|
||||||
});
|
});
|
||||||
|
@ -200,12 +210,6 @@ function AppWrapper() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
|
|
||||||
// Enable/disable automatic updates download based on user's settings.
|
|
||||||
const state = store.getState();
|
|
||||||
const autoUpdatesDisabled = makeSelectClientSetting(SETTINGS.DISABLE_AUTO_UPDATES)(state);
|
|
||||||
autoUpdater.autoDownload = !autoUpdatesDisabled;
|
|
||||||
|
|
||||||
moment.locale(remote.app.getLocale());
|
moment.locale(remote.app.getLocale());
|
||||||
|
|
||||||
autoUpdater.on('error', (error) => {
|
autoUpdater.on('error', (error) => {
|
||||||
|
|
|
@ -37,7 +37,7 @@ import {
|
||||||
selectModal,
|
selectModal,
|
||||||
selectAllowAnalytics,
|
selectAllowAnalytics,
|
||||||
} from 'redux/selectors/app';
|
} from 'redux/selectors/app';
|
||||||
import { selectDaemonSettings, makeSelectClientSetting } from 'redux/selectors/settings';
|
import { selectDaemonSettings, makeSelectClientSetting, selectDisableAutoUpdates } from 'redux/selectors/settings';
|
||||||
import { selectUser } from 'redux/selectors/user';
|
import { selectUser } from 'redux/selectors/user';
|
||||||
import { doSyncLoop, doSetPrefsReady, doPreferenceGet, doPopulateSharedUserState } from 'redux/actions/sync';
|
import { doSyncLoop, doSetPrefsReady, doPreferenceGet, doPopulateSharedUserState } from 'redux/actions/sync';
|
||||||
import { doAuthenticate } from 'redux/actions/user';
|
import { doAuthenticate } from 'redux/actions/user';
|
||||||
|
@ -187,10 +187,13 @@ export function doCheckUpgradeAvailable() {
|
||||||
// On Windows, Mac, and AppImage, updates happen silently through
|
// On Windows, Mac, and AppImage, updates happen silently through
|
||||||
// electron-updater.
|
// electron-updater.
|
||||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||||
|
const disableAutoUpdate = selectDisableAutoUpdates(state);
|
||||||
|
|
||||||
if (!autoUpdateDeclined && !isDev) {
|
if (autoUpdateDeclined || isDev) {
|
||||||
ipcRenderer.send('check-for-updates');
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcRenderer.send('check-for-updates', !disableAutoUpdate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,3 +83,5 @@ export const selectHomepageData = createSelector(
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectosNotificationsEnabled = makeSelectClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED);
|
export const selectosNotificationsEnabled = makeSelectClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED);
|
||||||
|
|
||||||
|
export const selectDisableAutoUpdates = makeSelectClientSetting(SETTINGS.DISABLE_AUTO_UPDATES);
|
||||||
|
|
Loading…
Reference in a new issue