Skip to content

Commit

Permalink
add debug logging and second instance event
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkav committed Nov 3, 2022
1 parent 862de1a commit 860d94a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/insomnia/src/main.development.ts
Expand Up @@ -132,6 +132,7 @@ app.on('activate', (_error, hasVisibleWindows) => {
// Create a new window when clicking the doc icon if there isn't one open
if (!hasVisibleWindows) {
try {
console.log('[main] creating new window for MacOS activate event');
windowUtils.createWindow();
} catch (error) {
// This might happen if 'ready' hasn't fired yet. So we're just going
Expand Down Expand Up @@ -159,19 +160,22 @@ const _launchApp = async () => {
console.error('[app] Failed to get instance lock');
app.quit();
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
app.on('second-instance', (_1, args) => {
console.log('Second instance listener recieved:', args.join('||'));
if (window) {
if (window.isMinimized()) {
window.restore();
}
window.focus();
}
const lastArg = args.slice(-1).join();
console.log('[main] Open Deep Link URL sent from second instance', lastArg);
window.webContents.send('shell:open', lastArg);
});
window = windowUtils.createWindow();

// Handle URLs when app already open
app.addListener('open-url', (_event, url) => {
app.on('open-url', (_event, url) => {
console.log('[main] Open Deep Link URL', url);
window.webContents.send('shell:open', url);
});
}
Expand Down

0 comments on commit 860d94a

Please sign in to comment.