Skip to content

Commit

Permalink
Fix duplicate window creation in mailto handling, #2968
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbotris authored and sarashub committed Oct 18, 2021
1 parent 7c78067 commit ab75574
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/desktop/DesktopMain.js
Expand Up @@ -161,16 +161,17 @@ async function startupInstance(components: Components) {

sse.start().catch(e => log.warn("unable to start sse client", e))

// The second-instance event fires when we call app.requestSingleInstanceLock inside of DesktopUtils.makeSingleInstance
app.on('second-instance', async (ev, args) => {
if (await desktopUtils.singleInstanceLockOverridden()) {
app.quit()
} else {
if (wm.getAll().length === 0) {
wm.newWindow(true)
await wm.newWindow(true)
} else {
wm.getAll().forEach(w => w.show())
}
handleMailto(findMailToUrlInArgv(args), components)
await handleMailto(findMailToUrlInArgv(args), components)
}
}).on('open-url', (e, url) => {
// MacOS mailto handling
Expand Down Expand Up @@ -206,7 +207,7 @@ async function onAppReady(components: Components) {
ipc.initialized(w.id).then(() => main(components))
}

function main(components: Components) {
async function main(components: Components) {
const {tray, notifier, sock, wm, updater, integrator} = components
tray.update(notifier)
if (process.argv.indexOf('-s') !== -1) {
Expand All @@ -224,7 +225,7 @@ function main(components: Components) {
updater.start()
integrator.runIntegration(wm)
if (opts.mailTo) {
handleMailto(opts.mailTo, components)
await handleMailto(opts.mailTo, components)
}
}

Expand Down
6 changes: 3 additions & 3 deletions start-desktop.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
if [[ $OSTYPE = darwin* ]]; then
ELECTRON_ENABLE_SECURITY_WARNINGS=TRUE ./node_modules/.bin/electron --inspect=5858 ./build/
ELECTRON_ENABLE_SECURITY_WARNINGS=TRUE ./node_modules/.bin/electron --inspect=5858 ./build/ $1
else
ELECTRON_ENABLE_SECURITY_WARNINGS=TRUE ./node_modules/.bin/electron --inspect=5858 ./build/
fi
ELECTRON_ENABLE_SECURITY_WARNINGS=TRUE ./node_modules/.bin/electron --inspect=5858 ./build/ $1
fi

0 comments on commit ab75574

Please sign in to comment.