Skip to content

Commit 8922324

Browse files
committed
Add audio & video permission request for cataline
1 parent 17afa84 commit 8922324

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/stores/AppStore.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const autoLauncher = new AutoLaunch({
4242
});
4343

4444
const CATALINA_NOTIFICATION_HACK_KEY = '_temp_askedForCatalinaNotificationPermissions';
45+
const CATALINA_AUDIO_HACK_KEY = '_temp_askedForCatalinaAudioPermissions';
4546

4647
export default class AppStore extends Store {
4748
updateStatusTypes = {
@@ -185,8 +186,6 @@ export default class AppStore extends Store {
185186

186187
this._healthCheck();
187188

188-
console.log(nativeTheme);
189-
190189
this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors;
191190

192191
onVisibilityChange((isVisible) => {
@@ -223,13 +222,23 @@ export default class AppStore extends Store {
223222
// macOS catalina notifications hack
224223
// notifications got stuck after upgrade but forcing a notification
225224
// via `new Notification` triggered the permission request
226-
if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) {
227-
// eslint-disable-next-line no-new
228-
new window.Notification('Welcome to Franz 5', {
229-
body: 'Have a wonderful day & happy messaging.',
230-
});
225+
if (isMac) {
226+
if (!localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) {
227+
// eslint-disable-next-line no-new
228+
new window.Notification('Welcome to Franz 5', {
229+
body: 'Have a wonderful day & happy messaging.',
230+
});
231231

232-
localStorage.setItem(CATALINA_NOTIFICATION_HACK_KEY, true);
232+
localStorage.setItem(CATALINA_NOTIFICATION_HACK_KEY, true);
233+
}
234+
235+
if (!localStorage.getItem(CATALINA_AUDIO_HACK_KEY)) {
236+
// eslint-disable-next-line no-new
237+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
238+
stream.getTracks().forEach(track => track.stop());
239+
240+
localStorage.setItem(CATALINA_AUDIO_HACK_KEY, true);
241+
}
233242
}
234243

235244
statsEvent('app-start');

0 commit comments

Comments
 (0)