Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
MenuItemConstructorOptions,
systemPreferences,
nativeTheme,
powerMonitor,
} from 'electron';
import {ipcMain as ipc} from 'electron-better-ipc';
import {autoUpdater} from 'electron-updater';
Expand Down Expand Up @@ -430,6 +431,15 @@ function createMainWindow(): BrowserWindow {

const {webContents} = mainWindow;

// Reload the page on system resume to restore the Messenger connection,
// which is lost when the computer sleeps. Wait for network connectivity
// before reloading to avoid a blank page on slow reconnects.
// See: https://github.com/sindresorhus/caprine/issues/103
powerMonitor.on('resume', async () => {
await ensureOnline();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid interactive offline prompt in resume handler

Calling ensureOnline() in the powerMonitor resume callback makes every wake-from-sleep path inherit startup behavior that shows a synchronous “Wait/Quit” dialog (and can call app.quit()) when connectivity is missing for ~15 seconds. In practice, users who resume without network (airplane/train, captive portal, Wi‑Fi still reconnecting) can get an unexpected blocking prompt or have the app quit even though they did not explicitly relaunch; this is a regression in the resume flow and should use a non-interactive connectivity wait/fallback.

Useful? React with 👍 / 👎.

webContents.reload();
});

webContents.on('dom-ready', async () => {
// Set window title to Caprine
mainWindow.setTitle(app.name);
Expand Down
Loading