Skip to content

Commit

Permalink
Handle mailto in argv
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmev committed Jun 23, 2021
1 parent 041d8ca commit e4984b5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export function shouldLaunchMinimized() {
)
}

const handleMailto = (mailto) =>
sendToSelectedAccountView('gmail:compose-mail', mailto.split(':')[1])

export async function initApp() {
app.setAppUserModelId(appId)

Expand All @@ -35,20 +38,24 @@ export async function initApp() {
app.disableHardwareAcceleration()
}

app.on('second-instance', () => {
app.on('second-instance', (_, argv) => {
const mainWindow = getMainWindow()

if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}

mainWindow.show()

const mailto = argv[argv.length - 1]
if (mailto.startsWith('mailto:')) {
handleMailto(mailto)
}
}
})

app.on('open-url', (_event, mailto) => {
sendToSelectedAccountView('gmail:compose-mail', mailto.split(':')[1])
handleMailto(mailto)
})

app.on('activate', () => {
Expand Down

0 comments on commit e4984b5

Please sign in to comment.