Skip to content

Commit 4aa48a6

Browse files
authored
fix(export): show the folder via the main process COMPASS-7671 (#5500)
* show the folder via the main process * use hadron-ipc and add a comment * hadron-ipc is a dep
1 parent 1656146 commit 4aa48a6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

packages/compass-import-export/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"electron": "^28.2.1",
6767
"hadron-app-registry": "^9.1.6",
6868
"hadron-document": "^8.4.7",
69+
"hadron-ipc": "^3.2.10",
6970
"mongodb-data-service": "^22.17.4",
7071
"react": "^17.0.2"
7172
},
@@ -80,6 +81,7 @@
8081
"electron": "^28.2.1",
8182
"hadron-app-registry": "^9.1.6",
8283
"hadron-document": "^8.4.7",
84+
"hadron-ipc": "^3.2.10",
8385
"mongodb-data-service": "^22.17.4"
8486
},
8587
"devDependencies": {

packages/compass-import-export/src/utils/reveal-file.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* to a highlighted path of `fileName` (e.g. "Show in Finder" on macOS)
44
* using the builtin electron API.
55
**/
6+
import { ipcRenderer } from 'hadron-ipc';
7+
68
export default function revealFile(fileName: string) {
7-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/consistent-type-imports
8-
const { shell }: typeof import('electron') = require('electron');
9-
shell.showItemInFolder(fileName);
9+
// electron.shell.showItemInFolder(filename); was crashing Finder on macOS
10+
// when called from the renderer process. Doing it on main rather seems to
11+
// work fine.
12+
ipcRenderer?.send('show-file', fileName);
1013
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ class CompassWindowManager {
351351
'test:show-connect-window': () => showConnectWindow(compassApp),
352352
});
353353

354+
ipcMain?.on('show-file', (evt, filename: string) => {
355+
shell.showItemInFolder(filename);
356+
});
357+
354358
await electronApp.whenReady();
355359
await onAppReady();
356360

0 commit comments

Comments
 (0)