Skip to content

Commit 0b1f019

Browse files
committed
fix(compass): disable spellcheck before creating browser window when network traffic disabled
1 parent d61a83c commit 0b1f019

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

packages/compass/src/main/application.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ class CompassApplication {
129129
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
130130
// https://github.com/electron/electron/issues/33640
131131
await app.whenReady();
132+
133+
const { networkTraffic } = this.preferences.getPreferences();
134+
135+
if (!networkTraffic) {
136+
// Electron fetches spellcheck dictionaries from a CDN
137+
// on all OSs expect mac (it provides a built-in spell check).
138+
// Passing a non-resolving URL prevents it from fetching
139+
// as there aren't any options to disable it provided.
140+
// https://github.com/electron/electron/issues/22995
141+
session.defaultSession.setSpellCheckerDictionaryDownloadURL(
142+
'http://127.0.0.1:0/'
143+
);
144+
}
145+
132146
log.info(
133147
mongoLogId(1_001_000_307),
134148
'Application',

packages/compass/src/main/window-manager.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* https://github.com/atom/electron/blob/main/docs/api/browser-window.md
44
*/
55
import { pathToFileURL } from 'url';
6+
import fs from 'fs';
7+
import os from 'os';
68
import path from 'path';
79
import type { HadronIpcMainEvent } from 'hadron-ipc';
810
import { ipcMain } from 'hadron-ipc';
@@ -82,6 +84,10 @@ async function showWindowWhenReady(bw: BrowserWindow) {
8284
bw.show();
8385
}
8486

87+
// function readLogFile() {
88+
89+
// }
90+
8591
/**
8692
* Call me instead of using `new BrowserWindow()` directly because i'll:
8793
*
@@ -140,8 +146,6 @@ function showConnectWindow(
140146
};
141147

142148
debug('creating new main window:', windowOpts);
143-
const { preferences } = compassApp;
144-
const { networkTraffic } = preferences.getPreferences();
145149

146150
let window: BrowserWindow | null = new BrowserWindow(windowOpts);
147151
if (mongodbUrl) {
@@ -150,12 +154,6 @@ function showConnectWindow(
150154
if (connectionId) {
151155
registerConnectionIdForBrowserWindow(window, connectionId);
152156
}
153-
if (networkTraffic !== true) {
154-
// https://github.com/electron/electron/issues/22995
155-
window.webContents.session.setSpellCheckerDictionaryDownloadURL(
156-
'http://127.0.0.1:0/'
157-
);
158-
}
159157

160158
enable(window.webContents);
161159
const unsubscribeProxyListenerPromise = compassApp.setupProxySupport(

0 commit comments

Comments
 (0)