Skip to content

Commit

Permalink
Merge pull request #8220 from vilmibm/8156-openExternal
Browse files Browse the repository at this point in the history
use openExternal async
  • Loading branch information
Nate Smith committed Sep 10, 2019
2 parents 46a9980 + 1448b6d commit 284e374
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/main-process/main.ts
Expand Up @@ -486,7 +486,7 @@ app.on('ready', () => {

ipcMain.on(
'open-external',
(event: Electron.IpcMessageEvent, { path }: { path: string }) => {
async (event: Electron.IpcMessageEvent, { path }: { path: string }) => {
const pathLowerCase = path.toLowerCase()
if (
pathLowerCase.startsWith('http://') ||
Expand All @@ -495,7 +495,14 @@ app.on('ready', () => {
log.info(`opening in browser: ${path}`)
}

const result = shell.openExternal(path)
let result
try {
await shell.openExternal(path)
result = true
} catch (e) {
log.error(`Call to openExternal failed: '${e}'`)
result = false
}
event.sender.send('open-external-result', { result })
}
)
Expand Down

0 comments on commit 284e374

Please sign in to comment.