This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auto-updater): set progress bar and add to menu
fixes #84
- Loading branch information
Showing
3 changed files
with
38 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,26 @@ | ||
import { sendStatusToWindow } from './electron'; | ||
import { dialog } from 'electron'; | ||
import { BrowserWindow, dialog } from 'electron'; | ||
import { autoUpdater } from 'electron-updater'; | ||
|
||
// autoUpdater.logger = log; | ||
|
||
export function checkForUpdates(): void { | ||
export function checkForUpdates(win: BrowserWindow): void { | ||
autoUpdater.checkForUpdatesAndNotify().catch(() => { | ||
sendStatusToWindow('Error in auto-updater.'); | ||
dialog.showErrorBox('Check for Updates', 'Error while checking for updates'); | ||
}); | ||
} | ||
|
||
autoUpdater.checkForUpdatesAndNotify().catch(() => { | ||
sendStatusToWindow('Error in auto-updater.'); | ||
}); | ||
|
||
autoUpdater.on('checking-for-update', info => { | ||
sendStatusToWindow('Checking for update...'); | ||
}); | ||
|
||
autoUpdater.on('update-available', info => { | ||
sendStatusToWindow('Update available.'); | ||
dialog.showMessageBox({ message: `There is a new Alva version: ${info.version}` }); | ||
}); | ||
|
||
autoUpdater.on('update-not-available', info => { | ||
sendStatusToWindow('Update not available.'); | ||
}); | ||
autoUpdater.on('update-available', info => { | ||
dialog.showMessageBox({ message: `There is a new Alva version: ${info.version}` }); | ||
}); | ||
|
||
autoUpdater.on('error', err => { | ||
sendStatusToWindow(`Error in auto-updater. ${err}`); | ||
}); | ||
autoUpdater.on('error', () => { | ||
dialog.showErrorBox('Check for Updates', 'Error on receiving update. Please try manually'); | ||
}); | ||
|
||
autoUpdater.on('download-progress', progressObj => { | ||
let log_message = `Download speed: ${progressObj.bytesPerSecond}`; | ||
log_message = `${log_message} - Downloaded ${progressObj.percent}%`; | ||
log_message = `${log_message} (${progressObj.transferred}/${progressObj.total})`; | ||
sendStatusToWindow(log_message); | ||
}); | ||
autoUpdater.on('download-progress', progressObj => { | ||
win.setProgressBar(progressObj.percent); | ||
}); | ||
|
||
autoUpdater.on('update-downloaded', info => { | ||
sendStatusToWindow('Update downloaded'); | ||
}); | ||
autoUpdater.on('update-downloaded', info => { | ||
dialog.showMessageBox({ message: 'Update downloaded. Will be installed on next restart' }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters