Skip to content

Commit

Permalink
possible fix for the missing camera permission popup (#3252)
Browse files Browse the repository at this point in the history
* possible fix for the missing camera permission popup

That apple review does not reject our app.

* add changelog entry
  • Loading branch information
Simon-Laux authored Jun 14, 2023
1 parent 2a55903 commit dafe938
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- update in-app help (2023-06-07)
- If clipboard contains a file and text, then only paste the file into deltachat. #3261

### Fixed
- possibly fix asking for camera permission on MacOS #3252

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

## [1.37.0] - 2023-06-05
Expand Down
19 changes: 17 additions & 2 deletions src/main/windows/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import debounce from 'debounce'
import electron, { BrowserWindow, Rectangle, session } from 'electron'
import electron, {
BrowserWindow,
Rectangle,
session,
systemPreferences,
} from 'electron'
import { appWindowTitle } from '../../shared/constants'
import { getLogger } from '../../shared/logger'
import { appIcon, windowDefaults, htmlDistDir } from '../application-constants'
Expand Down Expand Up @@ -126,11 +131,21 @@ export function init(options: { hidden: boolean }) {
}
}
window.webContents.session.setPermissionCheckHandler((_wc, permission) => {
if (permission === 'camera') {
return systemPreferences.getMediaAccessStatus('camera') === 'granted'
}
// if (permission === "microphone") {
// return systemPreferences.getMediaAccessStatus("microphone") === "granted"
// }
return permission_handler(permission as any)
})
window.webContents.session.setPermissionRequestHandler(
(_wc, permission, callback) => {
callback(permission_handler(permission))
if (permission === 'media') {
systemPreferences.askForMediaAccess('camera').then(callback)
} else {
callback(permission_handler(permission))
}
}
)
}
Expand Down

0 comments on commit dafe938

Please sign in to comment.