browserWindows.ts: Add catch for Set/GetRepresentedFilename

It's not supported on all platforms
This commit is contained in:
softworkz
2025-11-09 02:36:41 +01:00
parent dd465baebf
commit dc27511aa5
2 changed files with 36 additions and 5 deletions

View File

@@ -444,10 +444,27 @@ module.exports = (socket, app) => {
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
});
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
getWindowById(id).setRepresentedFilename(filename);
const win = getWindowById(id);
try {
if (win && typeof win.setRepresentedFilename === 'function') {
win.setRepresentedFilename(filename);
}
}
catch (e) {
console.warn('setRepresentedFilename failed (likely unsupported platform):', e);
}
});
socket.on('browserWindowGetRepresentedFilename', (id) => {
const pathname = getWindowById(id).getRepresentedFilename();
const win = getWindowById(id);
let pathname = '';
try {
if (win && typeof win.getRepresentedFilename === 'function') {
pathname = win.getRepresentedFilename() || '';
}
}
catch (e) {
console.warn('getRepresentedFilename failed (likely unsupported platform):', e);
}
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
});
socket.on('browserWindowSetDocumentEdited', (id, edited) => {

View File

@@ -566,12 +566,26 @@ export = (socket: Socket, app: Electron.App) => {
});
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
getWindowById(id).setRepresentedFilename(filename);
const win = getWindowById(id);
try {
if (win && typeof win.setRepresentedFilename === 'function') {
win.setRepresentedFilename(filename);
}
} catch (e) {
console.warn('setRepresentedFilename failed (likely unsupported platform):', e);
}
});
socket.on('browserWindowGetRepresentedFilename', (id) => {
const pathname = getWindowById(id).getRepresentedFilename();
const win = getWindowById(id);
let pathname = '';
try {
if (win && typeof win.getRepresentedFilename === 'function') {
pathname = win.getRepresentedFilename() || '';
}
} catch (e) {
console.warn('getRepresentedFilename failed (likely unsupported platform):', e);
}
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
});