mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-09-28 20:29:04 +00:00
* Only add a new window handler to the main window * Update app/src/components/mainWindow.ts Co-authored-by: Ronan Jouchet <ronan@jouchet.fr> Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
This commit is contained in:
parent
460d70f915
commit
363fa966ee
@ -11,7 +11,7 @@ import {
|
|||||||
isOSX,
|
isOSX,
|
||||||
nativeTabsSupported,
|
nativeTabsSupported,
|
||||||
} from '../helpers/helpers';
|
} from '../helpers/helpers';
|
||||||
import { setupNativefierWindow } from '../helpers/windowEvents';
|
import { onNewWindow, setupNativefierWindow } from '../helpers/windowEvents';
|
||||||
import {
|
import {
|
||||||
clearCache,
|
clearCache,
|
||||||
getDefaultWindowOptions,
|
getDefaultWindowOptions,
|
||||||
@ -88,6 +88,32 @@ export async function createMainWindow(
|
|||||||
createContextMenu(options, mainWindow);
|
createContextMenu(options, mainWindow);
|
||||||
setupNativefierWindow(options, mainWindow);
|
setupNativefierWindow(options, mainWindow);
|
||||||
|
|
||||||
|
// .on('new-window', ...) is deprected in favor of setWindowOpenHandler(...)
|
||||||
|
// We can't quite cut over to that yet for a few reasons:
|
||||||
|
// 1. Our version of Electron does not yet support a parameter to
|
||||||
|
// setWindowOpenHandler that contains `disposition', which we need.
|
||||||
|
// See https://github.com/electron/electron/issues/28380
|
||||||
|
// 2. setWindowOpenHandler doesn't support newGuest as well
|
||||||
|
// Though at this point, 'new-window' bugs seem to be coming up and downstream
|
||||||
|
// users are being pointed to use setWindowOpenHandler.
|
||||||
|
// E.g., https://github.com/electron/electron/issues/28374
|
||||||
|
|
||||||
|
// Note it is important to add this handler only to the *main* window,
|
||||||
|
// else we run into weird behavior like opening tabs twice
|
||||||
|
mainWindow.webContents.on(
|
||||||
|
'new-window',
|
||||||
|
(event, url, frameName, disposition) => {
|
||||||
|
onNewWindow(
|
||||||
|
options,
|
||||||
|
setupNativefierWindow,
|
||||||
|
event,
|
||||||
|
url,
|
||||||
|
frameName,
|
||||||
|
disposition,
|
||||||
|
).catch((err) => log.error('onNewWindow ERROR', err));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (options.counter) {
|
if (options.counter) {
|
||||||
setupCounter(options, mainWindow, setDockBadge);
|
setupCounter(options, mainWindow, setDockBadge);
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,26 +151,6 @@ export function setupNativefierWindow(options, window: BrowserWindow): void {
|
|||||||
|
|
||||||
injectCSS(window);
|
injectCSS(window);
|
||||||
|
|
||||||
// .on('new-window', ...) is deprected in favor of setWindowOpenHandler(...)
|
|
||||||
// We can't quite cut over to that yet for a few reasons:
|
|
||||||
// 1. Our version of Electron does not yet support a parameter to
|
|
||||||
// setWindowOpenHandler that contains `disposition', which we need.
|
|
||||||
// See https://github.com/electron/electron/issues/28380
|
|
||||||
// 2. setWindowOpenHandler doesn't support newGuest as well
|
|
||||||
// Though at this point, 'new-window' bugs seem to be coming up and downstream
|
|
||||||
// users are being pointed to use setWindowOpenHandler.
|
|
||||||
// E.g., https://github.com/electron/electron/issues/28374
|
|
||||||
|
|
||||||
window.webContents.on('new-window', (event, url, frameName, disposition) => {
|
|
||||||
onNewWindow(
|
|
||||||
options,
|
|
||||||
setupNativefierWindow,
|
|
||||||
event,
|
|
||||||
url,
|
|
||||||
frameName,
|
|
||||||
disposition,
|
|
||||||
).catch((err) => log.error('onNewWindow ERROR', err));
|
|
||||||
});
|
|
||||||
window.webContents.on('will-navigate', (event: IpcMainEvent, url: string) => {
|
window.webContents.on('will-navigate', (event: IpcMainEvent, url: string) => {
|
||||||
onWillNavigate(options, event, url).catch((err) => {
|
onWillNavigate(options, event, url).catch((err) => {
|
||||||
log.error(' window.webContents.on.will-navigate ERROR', err);
|
log.error(' window.webContents.on.will-navigate ERROR', err);
|
||||||
|
Loading…
Reference in New Issue
Block a user