automatic updates notes

This commit is contained in:
zeppi 2022-02-17 15:45:35 -05:00
parent 67608dfc9c
commit a2823f33c8
4 changed files with 24 additions and 12 deletions

View file

@ -289,6 +289,8 @@ app.on('before-quit', () => {
ipcMain.on('download-upgrade', async (event, params) => { ipcMain.on('download-upgrade', async (event, params) => {
const { url, options } = params; const { url, options } = params;
const dir = fs.mkdtempSync(app.getPath('temp') + path.sep); const dir = fs.mkdtempSync(app.getPath('temp') + path.sep);
// tell app of new tempdir
rendererWindow.webContents.send('update-download-path', dir);
options.onProgress = function(p) { options.onProgress = function(p) {
rendererWindow.webContents.send('download-progress-update', p); rendererWindow.webContents.send('download-progress-update', p);
}; };
@ -318,7 +320,8 @@ ipcMain.on('check-for-updates', () => {
autoUpdater.checkForUpdates(); autoUpdater.checkForUpdates();
}); });
autoUpdater.on('update-downloaded', () => { autoUpdater.on('update-downloaded', (e, releaseNotes, releaseName) => {
rendererWindow.webContents.send('log-this', {e, releaseNotes, releaseName});
autoUpdateDownloaded = true; autoUpdateDownloaded = true;
}); });

View file

@ -118,6 +118,7 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
}); });
ipcRenderer.on('download-progress-update', (e, p) => { ipcRenderer.on('download-progress-update', (e, p) => {
console.log('e', e, 'p', p);
app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100))); app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100)));
}); });
@ -146,12 +147,21 @@ ipcRenderer.on('zoom-window', (event, action) => {
const { dock } = remote.app; const { dock } = remote.app;
ipcRenderer.on('log-this', (e, log) => {
console.log('electron log:', log);
});
ipcRenderer.on('window-is-focused', () => { ipcRenderer.on('window-is-focused', () => {
if (!dock) return; if (!dock) return;
app.store.dispatch({ type: ACTIONS.WINDOW_FOCUSED }); app.store.dispatch({ type: ACTIONS.WINDOW_FOCUSED });
dock.setBadge(''); dock.setBadge('');
}); });
ipcRenderer.on('update-download-path', (dir) => {
console.log('dir');
// doLogWarningConsoleMessage();
});
ipcRenderer.on('devtools-is-opened', () => { ipcRenderer.on('devtools-is-opened', () => {
doLogWarningConsoleMessage(); doLogWarningConsoleMessage();
}); });
@ -191,8 +201,9 @@ function AppWrapper() {
useEffect(() => { useEffect(() => {
if (persistDone) { if (persistDone) {
const state = store.getState(); const state = store.getState();
const enabled = makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state); const prereleaseEnabled = makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state);
if (enabled) { // const autoUpdateEnabled = makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state);
if (prereleaseEnabled) {
autoUpdater.allowPrerelease = true; autoUpdater.allowPrerelease = true;
} }
} }

View file

@ -3,13 +3,13 @@ import { doStartUpgrade, doCancelUpgrade, doHideModal } from 'redux/actions/app'
import { selectDownloadProgress, selectDownloadComplete, selectUpgradeDownloadPath } from 'redux/selectors/app'; import { selectDownloadProgress, selectDownloadComplete, selectUpgradeDownloadPath } from 'redux/selectors/app';
import ModalDownloading from './view'; import ModalDownloading from './view';
const select = state => ({ const select = (state) => ({
downloadProgress: selectDownloadProgress(state), downloadProgress: selectDownloadProgress(state),
downloadComplete: selectDownloadComplete(state), downloadComplete: selectDownloadComplete(state),
downloadItem: selectUpgradeDownloadPath(state), downloadItem: selectUpgradeDownloadPath(state), // update or clear this when download (Re)starts
}); });
const perform = dispatch => ({ const perform = (dispatch) => ({
startUpgrade: () => dispatch(doStartUpgrade()), startUpgrade: () => dispatch(doStartUpgrade()),
cancelUpgrade: () => { cancelUpgrade: () => {
dispatch(doHideModal()); dispatch(doHideModal());
@ -17,7 +17,4 @@ const perform = dispatch => ({
}, },
}); });
export default connect( export default connect(select, perform)(ModalDownloading);
select,
perform
)(ModalDownloading);

View file

@ -83,7 +83,8 @@ export function doSkipUpgrade() {
export function doStartUpgrade() { export function doStartUpgrade() {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
const upgradeDownloadPath = selectUpgradeDownloadPath(state); const upgradeDownloadPath = selectUpgradeDownloadPath(state); // downloadPath
// make sure downloadPath is updated as soon as download starts
ipcRenderer.send('upgrade', upgradeDownloadPath); ipcRenderer.send('upgrade', upgradeDownloadPath);
}; };
@ -92,7 +93,7 @@ export function doStartUpgrade() {
export function doDownloadUpgrade() { export function doDownloadUpgrade() {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
const url = selectUpdateUrl(state); const url = selectUpdateUrl(state); // updateUrl
ipcRenderer.send('download-upgrade', { url, options: {} }); ipcRenderer.send('download-upgrade', { url, options: {} });
dispatch({ dispatch({
type: ACTIONS.UPGRADE_DOWNLOAD_STARTED, type: ACTIONS.UPGRADE_DOWNLOAD_STARTED,