mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-30 03:59:07 +00:00
fixup! wip handle device in use
This commit is contained in:
+12
-6
@@ -5,16 +5,18 @@ import { css } from '@/styled-system/css'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
type PermissionNeededButtonProps = {
|
type PermissionNeededButtonProps = {
|
||||||
tooltip?: string
|
tooltip?: string | null
|
||||||
onPress?: () => void
|
onPress?: (() => void) | null
|
||||||
|
ariaLabel?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PermissionNeededButton = ({
|
export const PermissionNeededButton = ({
|
||||||
tooltip,
|
tooltip,
|
||||||
onPress,
|
onPress,
|
||||||
|
ariaLabel,
|
||||||
}: PermissionNeededButtonProps) => {
|
}: PermissionNeededButtonProps) => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'permissionsButton' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'permissionsButton' })
|
||||||
const label = tooltip ?? t('tooltip')
|
const label = tooltip === undefined ? t('tooltip') : tooltip
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={css({
|
className={css({
|
||||||
@@ -26,9 +28,13 @@ export const PermissionNeededButton = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
aria-label={tooltip ? label : t('ariaLabel')}
|
aria-label={ariaLabel ?? label ?? t('ariaLabel')}
|
||||||
tooltip={label}
|
tooltip={label ?? undefined}
|
||||||
onPress={onPress ?? (() => openPermissionsDialog())}
|
onPress={
|
||||||
|
onPress === undefined
|
||||||
|
? () => openPermissionsDialog()
|
||||||
|
: (onPress ?? undefined)
|
||||||
|
}
|
||||||
variant="permission"
|
variant="permission"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -206,11 +206,12 @@ export const ToggleDevice = <T extends ToggleSource>({
|
|||||||
)}
|
)}
|
||||||
{deviceInUse && (
|
{deviceInUse && (
|
||||||
<PermissionNeededButton
|
<PermissionNeededButton
|
||||||
tooltip={explainDeviceInUse ? t(`deviceInUse.${kind}`) : undefined}
|
tooltip={explainDeviceInUse ? t(`deviceInUse.${kind}`) : null}
|
||||||
|
ariaLabel={t(`deviceInUse.${kind}`)}
|
||||||
onPress={
|
onPress={
|
||||||
explainDeviceInUse
|
explainDeviceInUse
|
||||||
? () => setAlertError(MediaDeviceFailure.DeviceInUse)
|
? () => setAlertError(MediaDeviceFailure.DeviceInUse)
|
||||||
: undefined
|
: null
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const useWatchMediaDeviceErrors = (): MediaDeviceAlert & {
|
|||||||
const permissionKind = PERMISSION_BY_DEVICE_KIND[kind]
|
const permissionKind = PERMISSION_BY_DEVICE_KIND[kind]
|
||||||
switch (failure) {
|
switch (failure) {
|
||||||
case MediaDeviceFailure.DeviceInUse:
|
case MediaDeviceFailure.DeviceInUse:
|
||||||
noteDeviceInUse(permissionKind)
|
if (permissionKind) noteDeviceInUse(permissionKind)
|
||||||
setAlert({ error: failure, kind })
|
setAlert({ error: failure, kind })
|
||||||
break
|
break
|
||||||
case MediaDeviceFailure.NotFound:
|
case MediaDeviceFailure.NotFound:
|
||||||
|
|||||||
Reference in New Issue
Block a user