fix: fixes issue where Moments camera wouldn't properly start on desktop app (#2084)
This commit is contained in:
18
packages/desktop/app/javascripts/Main/Media/MediaManager.ts
Normal file
18
packages/desktop/app/javascripts/Main/Media/MediaManager.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { MediaManagerInterface } from './MediaManagerInterface'
|
||||
|
||||
const { systemPreferences } = require('electron')
|
||||
|
||||
export class MediaManager implements MediaManagerInterface {
|
||||
async askForMediaAccess(type: 'camera' | 'microphone'): Promise<boolean> {
|
||||
const permission = systemPreferences.getMediaAccessStatus(type)
|
||||
|
||||
if (permission === 'granted') {
|
||||
return true
|
||||
} else if (permission === 'denied') {
|
||||
return false
|
||||
}
|
||||
|
||||
const granted = await systemPreferences.askForMediaAccess(type)
|
||||
return granted
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface MediaManagerInterface {
|
||||
askForMediaAccess(type: 'camera' | 'microphone'): Promise<boolean>
|
||||
}
|
||||
Reference in New Issue
Block a user