Skip to content

Commit

Permalink
Propagate from main IPC into window manager
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Dec 19, 2024
1 parent f8ad9ac commit 5c2f774
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/compass/src/main/window-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { CompassApplication } from './application';
import {
getWindowAutoConnectPreferences,
registerMongoDbUrlForBrowserWindow,
registerConnectionIdForBrowserWindow,
} from './auto-connect';

const { debug } = createLogger('COMPASS-WINDOW-MANAGER');
Expand Down Expand Up @@ -95,16 +96,19 @@ async function showWindowWhenReady(bw: BrowserWindow) {
*/
function showConnectWindow(
compassApp: typeof CompassApplication,
opts: Partial<
{
rendererUrl = DEFAULT_URL,
mongodbUrl,
connectionId,
...opts
}: Partial<
BrowserWindowConstructorOptions & {
rendererUrl: string;
mongodbUrl: string;
connectionId: string;
}
> = {}
): BrowserWindow {
const rendererUrl = opts.rendererUrl ?? DEFAULT_URL;
const mongodbUrl = opts.mongodbUrl;

const windowOpts = {
width: Number(DEFAULT_WIDTH),
height: Number(DEFAULT_HEIGHT),
Expand Down Expand Up @@ -143,6 +147,9 @@ function showConnectWindow(
if (mongodbUrl) {
registerMongoDbUrlForBrowserWindow(window, mongodbUrl);
}
if (connectionId) {
registerConnectionIdForBrowserWindow(window, connectionId);
}
if (networkTraffic !== true) {
// https://github.com/electron/electron/issues/22995
window.webContents.session.setSpellCheckerDictionaryDownloadURL(
Expand Down Expand Up @@ -265,6 +272,8 @@ class CompassWindowManager {
return getWindowAutoConnectPreferences(bw, compassApp.preferences);
},
'test:show-connect-window': () => showConnectWindow(compassApp),
'app:connect-in-new-window': (event, connectionId: string) =>
showConnectWindow(compassApp, { connectionId }),
});

ipcMain?.on('show-file', (evt, filename: string) => {
Expand Down

0 comments on commit 5c2f774

Please sign in to comment.