mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-09 02:07:47 +00:00
browserWindows.ts: Add catch for Set/GetRepresentedFilename
It's not supported on all platforms
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user