Skip to content

Commit dc27511

Browse files
committed
browserWindows.ts: Add catch for Set/GetRepresentedFilename
It's not supported on all platforms
1 parent dd465ba commit dc27511

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/ElectronNET.Host/api/browserWindows.js

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/browserWindows.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,26 @@ export = (socket: Socket, app: Electron.App) => {
566566
});
567567

568568
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
569-
getWindowById(id).setRepresentedFilename(filename);
569+
const win = getWindowById(id);
570+
try {
571+
if (win && typeof win.setRepresentedFilename === 'function') {
572+
win.setRepresentedFilename(filename);
573+
}
574+
} catch (e) {
575+
console.warn('setRepresentedFilename failed (likely unsupported platform):', e);
576+
}
570577
});
571578

572579
socket.on('browserWindowGetRepresentedFilename', (id) => {
573-
const pathname = getWindowById(id).getRepresentedFilename();
574-
580+
const win = getWindowById(id);
581+
let pathname = '';
582+
try {
583+
if (win && typeof win.getRepresentedFilename === 'function') {
584+
pathname = win.getRepresentedFilename() || '';
585+
}
586+
} catch (e) {
587+
console.warn('getRepresentedFilename failed (likely unsupported platform):', e);
588+
}
575589
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
576590
});
577591

0 commit comments

Comments
 (0)