Skip to content

Commit

Permalink
fix: if systemPreferences.askForMediaAccess is not available, then do…
Browse files Browse the repository at this point in the history
…n't call it

(broke qr scan under linux (and maybe also under windows, was not tested))
  • Loading branch information
Simon-Laux committed Jun 21, 2023
1 parent 49aefcb commit 96598c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased][unreleased]


### Fixed
- fix: if systemPreferences.askForMediaAccess is not available, then don't call it (broke qr scan under linux (and maybe also under windows, was not tested))

<a id="1_38_0"></a>

## [1.38.0] - 2023-06-19
Expand Down
6 changes: 3 additions & 3 deletions src/main/windows/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ export function init(options: { hidden: boolean }) {
}
}
window.webContents.session.setPermissionCheckHandler((_wc, permission) => {
if (permission === 'camera') {
if (systemPreferences.getMediaAccessStatus && permission === 'camera') {
return systemPreferences.getMediaAccessStatus('camera') === 'granted'
}
// if (permission === "microphone") {
// if (systemPreferences.getMediaAccessStatus && permission === "microphone") {
// return systemPreferences.getMediaAccessStatus("microphone") === "granted"
// }
return permission_handler(permission as any)
})
window.webContents.session.setPermissionRequestHandler(
(_wc, permission, callback) => {
if (permission === 'media') {
if (systemPreferences.askForMediaAccess && permission === 'media') {
systemPreferences.askForMediaAccess('camera').then(callback)
} else {
callback(permission_handler(permission))
Expand Down

0 comments on commit 96598c5

Please sign in to comment.