Fix cannot convert undefined or null to object bug on Linux (#183)

This commit is contained in:
Quang Lam 2020-03-30 18:45:01 +07:00 committed by GitHub
parent 249dbf06db
commit 357e791d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 18 deletions

View file

@ -103,6 +103,32 @@ if (!gotTheLock) {
});
ipcMain.emit('request-update-pause-notifications-info');
})
.then(() => {
// Fix webview is not resized automatically
// when window is maximized on Linux
// https://github.com/atomery/webcatalog/issues/561
// run it here not in mainWindow.createAsync()
// because if the `mainWindow` is maximized or minimized
// before the workspaces's BrowserView fully loaded
// error will occur
// see https://github.com/atomery/webcatalog/issues/637
if (process.platform === 'linux') {
const win = mainWindow.get();
const handleMaximize = () => {
// getContentSize is not updated immediately
// try once after 0.2s (for fast computer), another one after 1s (to be sure)
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 200);
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 1000);
};
win.on('maximize', handleMaximize);
win.on('unmaximize', handleMaximize);
}
});
};

View file

@ -208,24 +208,6 @@ const createAsync = () => {
}
});
// Fix webview is not resized automatically
// when window is maximized on Linux
// https://github.com/atomery/webcatalog/issues/561
if (process.platform === 'linux') {
const handleMaximize = () => {
// getContentSize is not updated immediately
// try once after 0.2s (for fast computer), another one after 1s (to be sure)
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 200);
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 1000);
};
win.on('maximize', handleMaximize);
win.on('unmaximize', handleMaximize);
}
return new Promise((resolve) => {
win.once('ready-to-show', () => {
resolve();