refac: permission

This commit is contained in:
Timothy J. Baek 2024-06-07 15:12:34 -07:00
parent 508e8eb4b1
commit f92ef3211b

View File

@ -896,11 +896,20 @@
<button
class=" text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-850 transition rounded-full p-2 self-center"
type="button"
on:click={() => {
on:click={async () => {
if (selectedModels.length > 1) {
toast.error($i18n.t('Select only one model to call'));
} else {
return;
}
// check if user has access to getUserMedia
try {
await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
// If the user grants the permission, proceed to show the call overlay
showCallOverlay.set(true);
} catch (err) {
// If the user denies the permission or an error occurs, show an error message
toast.error($i18n.t('Permission denied when accessing media devices'));
}
}}
>