forked from internxt/drive-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PB-556] fix: workaround open external url in linux (internxt#303)
- Loading branch information
1 parent
3bfd1b4
commit fe034fb
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
import { ipcMain, shell } from 'electron'; | ||
import { exec } from 'child_process'; | ||
|
||
ipcMain.handle('get-platform', () => { | ||
return process.platform; | ||
}); | ||
|
||
ipcMain.handle('open-url', (_, url: string) => { | ||
|
||
if (process.platform === 'linux') { | ||
// shell.openExternal is not working as intended on the current verions of electron | ||
// this is only a workaround to fix it | ||
return new Promise<void>((resolve, reject) => { | ||
exec(`xdg-open ${url} &`, (error) => { | ||
if (error) reject(error); | ||
|
||
resolve(); | ||
}); | ||
}); | ||
|
||
} | ||
|
||
|
||
return shell.openExternal(url); | ||
}); |