fixup! wip handle device in use

This commit is contained in:
lebaudantoine
2026-08-22 23:38:42 +02:00
parent ef77157bc6
commit 359c4af098
3 changed files with 16 additions and 9 deletions
@@ -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: