Skip to content

Commit

Permalink
fix(electron) handle connectivity problems more gracefully
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
saghul committed Oct 17, 2023
1 parent 1c99423 commit 68392cb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spot-electron/src/application-window/applicationwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 68392cb

Please sign in to comment.