From 25f4adc7ad8537dadfca41c1a432f13e8ae9a4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 3 Jun 2021 10:17:38 +0200 Subject: [PATCH 1/3] Fixing Safari on MacOS compatibility The null safe operator is not recognized and was not encoded by Webpack in Svelte expressions (inside {}) + The Notification API of Safari is old and broken and we need to account for that. --- .../HorizontalSoundMeterWidget.svelte | 6 ++++- front/src/Components/SoundMeterWidget.svelte | 6 ++++- front/src/WebRtc/MediaManager.ts | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/front/src/Components/EnableCamera/HorizontalSoundMeterWidget.svelte b/front/src/Components/EnableCamera/HorizontalSoundMeterWidget.svelte index e7f721c1..84352ebb 100644 --- a/front/src/Components/EnableCamera/HorizontalSoundMeterWidget.svelte +++ b/front/src/Components/EnableCamera/HorizontalSoundMeterWidget.svelte @@ -10,9 +10,11 @@ let timeout; const soundMeter = new SoundMeter(); + let display = false; $: { if (stream && stream.getAudioTracks().length > 0) { + display = true; soundMeter.connectToSource(stream, new AudioContext()); if (timeout) { @@ -28,6 +30,8 @@ } }, 100); + } else { + display = false; } } @@ -53,7 +57,7 @@ -
0}> +
{#each [...Array(NB_BARS).keys()] as i}
{/each} diff --git a/front/src/Components/SoundMeterWidget.svelte b/front/src/Components/SoundMeterWidget.svelte index d96b9681..40c467b1 100644 --- a/front/src/Components/SoundMeterWidget.svelte +++ b/front/src/Components/SoundMeterWidget.svelte @@ -10,9 +10,11 @@ let timeout; const soundMeter = new SoundMeter(); + let display = false; $: { if (stream && stream.getAudioTracks().length > 0) { + display = true; soundMeter.connectToSource(stream, new AudioContext()); if (timeout) { @@ -28,6 +30,8 @@ } }, 100); + } else { + display = false; } } @@ -40,7 +44,7 @@ -
0}> +
1}> 2}> 3}> diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 180b5746..7b527962 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -440,12 +440,32 @@ export class MediaManager { public getNotification(){ //Get notification if (!DISABLE_NOTIFICATIONS && window.Notification && Notification.permission !== "granted") { - Notification.requestPermission().catch((err) => { - console.error(`Notification permission error`, err); - }); + if (this.checkNotificationPromise()) { + Notification.requestPermission().catch((err) => { + console.error(`Notification permission error`, err); + }); + } else { + Notification.requestPermission(); + } } } + /** + * Return true if the browser supports the modern version of the Notification API (which is Promise based) or false + * if we are on Safari... + * + * See https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API + */ + private checkNotificationPromise(): boolean { + try { + Notification.requestPermission().then(); + } catch(e) { + return false; + } + + return true; + } + public createNotification(userName: string){ if(this.focused){ return; From eb6cfdf53d74dbd7e1352abb57760575e85ca1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 3 Jun 2021 10:39:30 +0200 Subject: [PATCH 2/3] Fixing missing early return if webcam not available --- front/src/Stores/MediaStore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front/src/Stores/MediaStore.ts b/front/src/Stores/MediaStore.ts index 6d6fb4a8..dafdffc4 100644 --- a/front/src/Stores/MediaStore.ts +++ b/front/src/Stores/MediaStore.ts @@ -418,6 +418,7 @@ export const localStreamStore = derived, LocalS error: new Error('Unable to access your camera or microphone. You need to use a HTTPS connection.'), constraints }); + return; } else { //throw new Error('Unable to access your camera or microphone. Your browser is too old.'); set({ @@ -425,6 +426,7 @@ export const localStreamStore = derived, LocalS error: new Error('Unable to access your camera or microphone. Your browser is too old.'), constraints }); + return; } } From 5f562f49c3d16af5c14651b58963037944e6bd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 3 Jun 2021 10:49:12 +0200 Subject: [PATCH 3/3] Improving error message --- front/src/Stores/MediaStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Stores/MediaStore.ts b/front/src/Stores/MediaStore.ts index dafdffc4..7d1911a4 100644 --- a/front/src/Stores/MediaStore.ts +++ b/front/src/Stores/MediaStore.ts @@ -423,7 +423,7 @@ export const localStreamStore = derived, LocalS //throw new Error('Unable to access your camera or microphone. Your browser is too old.'); set({ type: 'error', - error: new Error('Unable to access your camera or microphone. Your browser is too old.'), + error: new Error('Unable to access your camera or microphone. Your browser is too old. Please consider upgrading your browser or try using a recent version of Chrome.'), constraints }); return;