Skip to content

Commit

Permalink
clean typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebouget committed Jul 3, 2024
1 parent 6d97ebb commit 9b1fd4b
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ app.on('will-finish-launching', function () {

if (win) {
setTimeout(() => {
win.webContents.send('file-open-system', fileToLoad);
win?.webContents?.send('file-open-system', fileToLoad);
}, 2500);
} else {
// if win is not ready, wait for it
app.once('browser-window-created', () => {
setTimeout(() => {
win.webContents.send('file-open-system', fileToLoad);
win?.webContents?.send('file-open-system', fileToLoad);
}, 2500);
});
}
Expand Down Expand Up @@ -176,8 +176,8 @@ ipcMain.handle('launch-check-for-update', async (event, arg) => {
});

function checkForUpdates() {
win.webContents
.executeJavaScript(
win?.webContents
?.executeJavaScript(
'localStorage.getItem("KHIOPS_VISUALIZATION_CHANNEL");',
true
)
Expand All @@ -193,7 +193,7 @@ function checkForUpdates() {
}

ipcMain.handle('set-title-bar-name', async (event, arg) => {
win.setTitle(arg && arg.title);
win.setTitle(arg?.title);
});

ipcMain.handle('set-dark-mode', () => {
Expand Down Expand Up @@ -227,26 +227,20 @@ autoUpdater.on('update-available', (info) => {
// }
// });
setTimeout(function () {
if (win && win.webContents) {
win.webContents.send('update-available', info);
}
win?.webContents?.send('update-available', info);
}, 2000);
});

autoUpdater.on('update-not-available', (info) => {
log.info('update-not-available', info);
setTimeout(function () {
if (win && win.webContents) {
win.webContents.send('update-not-available', info);
}
win?.webContents?.send('update-not-available', info);
}, 2000);
});

autoUpdater.on('download-progress', (progressObj) => {
log.info('download-progress', progressObj);
if (win && win.webContents) {
win.webContents.send('download-progress-info', progressObj);
}
win?.webContents?.send('download-progress-info', progressObj);
});

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
Expand Down Expand Up @@ -274,8 +268,6 @@ autoUpdater.on('error', (message) => {
log.info('error', message);

setTimeout(function () {
if (win && win.webContents) {
win.webContents.send('update-error', message);
}
win?.webContents?.send('update-error', message);
}, 2000);
});

0 comments on commit 9b1fd4b

Please sign in to comment.