fix of minor app crash when updating

this hopefully fixes an OS window manager freeze on Ubuntu..
This commit is contained in:
dj2ls 2022-02-23 10:14:46 +01:00
parent 31c1bcac36
commit 25ccb6b155
3 changed files with 33 additions and 11 deletions

View file

@ -156,9 +156,10 @@ function createWindow() {
win.once('ready-to-show', () => {
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater.autoDownload = true;
autoUpdater.checkForUpdatesAndNotify();
//autoUpdater.quitAndInstall();
});
@ -347,33 +348,46 @@ ipcMain.on('request-update-rx-msg-buffer', (event, arg) => {
// LISTENER FOR UPDATER EVENTS
autoUpdater.on('update-available', () => {
autoUpdater.on('update-available', (info) => {
console.log('update available');
console.log(info)
let arg = {
status: "update-available"
status: "update-available",
info: info
};
win.webContents.send('action-updater', arg);
});
autoUpdater.on('update-not-available', () => {
autoUpdater.on('update-not-available', (info) => {
console.log('update-not-available');
console.log(info)
let arg = {
status: "update-not-available"
status: "update-not-available",
info: info
};
win.webContents.send('action-updater', arg);
});
autoUpdater.on('update-downloaded', () => {
autoUpdater.on('update-downloaded', (info) => {
console.log('update downloaded');
let arg = {
status: "update-downloaded"
status: "update-downloaded",
info: info
};
win.webContents.send('action-updater', arg);
// we need to call this at this point.
// if an update is available and we are force closing the app
// the entire screen crashes...
autoUpdater.quitAndInstall();
});
autoUpdater.on('checking-for-update', () => {
let arg = {
status: "checking-for-update",
version: app.getVersion()

View file

@ -1640,6 +1640,10 @@ ipcRenderer.on('action-updater', (event, arg) => {
console.log(arg.status)
if (arg.status == "download-progress"){
bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateAvailable')).hide(); // close our update available notification
var progressinfo = '(' + Math.round(arg.progress.transferred/1024) + 'kB /' + Math.round(arg.progress.total/1024) + 'kB)';
document.getElementById("toastUpdateProgressInfo").innerHTML = progressinfo;
document.getElementById("toastUpdateProgressSpeed").innerHTML = Math.round(arg.progress.bytesPerSecond/1024) + "kByte/s";

View file

@ -111,14 +111,18 @@
<div class="toast bg-white" role="alert" data-bs-autohide="false" id="toastUpdateDownloaded" aria-live="assertive" aria-atomic="true">
<div class="toast-header"> <strong class="me-auto"> Update ready...</strong>
</div>
<div class="toast-body">Please restart the app for installation!</div>
<div class="toast-body">App is going to restart automatically...</div>
</div>
<!-- UPDATE AVAILABLE -->
<div class="toast bg-white" role="alert" data-bs-autohide="true" id="toastUpdateAvailable" aria-live="assertive" aria-atomic="true">
<div class="toast-header"> <i class="bi bi-cloud-arrow-down" style="font-size: 1rem; color: black;"></i><strong class="me-auto">Update available</strong>
<div class="toast align-items-center text-white bg-primary border-0" data-bs-autohide="false" id="toastUpdateAvailable" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body"> <i class="bi bi-activity" style="font-size: 1rem; color: black;"></i> Preparing for download...</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body"><i class="bi bi-cloud-arrow-down" style="font-size: 1rem; color: black;"></i>going to download...</div>
</div>
<!-- UPDATE NOT AVAILABLE -->
<div class="toast align-items-center text-white bg-success border-0" id="toastUpdateNotAvailable" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">