[Splash] Add better webcontentssend error handling and checking
This commit is contained in:
parent
5facca21e0
commit
3d55df0dee
1 changed files with 10 additions and 8 deletions
|
@ -69,8 +69,12 @@ exports.events = events;
|
||||||
function webContentsSend(win, event, ...args) {
|
function webContentsSend(win, event, ...args) {
|
||||||
// log('Splash', `Sending to webcontents:`, event, args);
|
// log('Splash', `Sending to webcontents:`, event, args);
|
||||||
|
|
||||||
if (win != null && win.webContents != null) {
|
if (splashWindow != null && !splashWindow.isDestroyed() && !splashWindow.webContents.isDestroyed()) {
|
||||||
win.webContents.send(`DISCORD_${event}`, ...args);
|
try {
|
||||||
|
win.webContents.send(`DISCORD_${event}`, ...args);
|
||||||
|
} catch (e) { // Mostly ignore, probably just destroyed
|
||||||
|
log('Splash', 'Failed to send to webcontents');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,12 +411,10 @@ function stopUpdateTimeout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSplashState(event) {
|
function updateSplashState(event) {
|
||||||
if (splashWindow != null && !splashWindow.isDestroyed() && !splashWindow.webContents.isDestroyed()) {
|
webContentsSend(splashWindow, 'SPLASH_UPDATE_STATE', {
|
||||||
webContentsSend(splashWindow, 'SPLASH_UPDATE_STATE', {
|
status: event,
|
||||||
status: event,
|
...splashState
|
||||||
...splashState
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchSplashWindow(startMinimized) {
|
function launchSplashWindow(startMinimized) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue