From 68392cb3dfedc85c585de18d3a27f5f9d4539539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 17 Oct 2023 14:52:43 +0200 Subject: [PATCH] fix(electron) handle connectivity problems more gracefully If we briefly go offline, the meeting will be closed. Instead, ignore offline events while in a meeting, since the network may come back up and the meeting would recover just fine. --- .../application-window/applicationwindow.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spot-electron/src/application-window/applicationwindow.js b/spot-electron/src/application-window/applicationwindow.js index 8ed3b2179..dd3263e1f 100644 --- a/spot-electron/src/application-window/applicationwindow.js +++ b/spot-electron/src/application-window/applicationwindow.js @@ -3,6 +3,7 @@ const isDev = require('electron-is-dev'); const process = require('process'); const { defaultSpotURL } = require('../../config'); +const { clientController } = require('../client-control'); const { logger, fileLogger } = require('../logger'); const { OnlineDetector } = require('../online-detector'); @@ -29,6 +30,20 @@ function createApplicationWindow() { let showCrashPageTimeout = null; + let meetingStatus = 0; /* Not in a meeting. */ + + clientController.addListener('meetingStatus', ({ status }) => { + logger.info(`Current meeting status: ${status}`); + + meetingStatus = status; + + // Re-evaluate if we should show the offline overlay after coming back from + // a meeting. + if (meetingStatus === 0 && !onlineDetector.getLastOnlineStatus()) { + applicationWindow.loadFile('src/static/offline.html'); + } + }); + applicationWindow = new BrowserWindow({ webPreferences: { contextIsolation: false, @@ -40,6 +55,14 @@ function createApplicationWindow() { onlineDetector.addListener(OnlineDetector.ONLINE_STATUS_CHANGED, isOnline => { clearTimeout(showCrashPageTimeout); + logger.warn(`Online status changed: ${isOnline}`); + + if (meetingStatus !== 0) { + logger.debug('Ignoring online state change while in a meeting'); + + return; + } + if (isOnline) { applicationWindow.loadURL(defaultSpotURL); } else {