@@ -37,14 +37,7 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
3737 const connectionError = useBluetoothAudioStore ( ( s ) => s . connectionError ) ;
3838 const [ hasScanned , setHasScanned ] = useState ( false ) ;
3939 const [ connectingDeviceId , setConnectingDeviceId ] = useState < string | null > ( null ) ;
40-
41- // Start scanning when sheet opens
42- useEffect ( ( ) => {
43- if ( isOpen && ! hasScanned ) {
44- startScan ( ) ;
45- }
46- // eslint-disable-next-line react-hooks/exhaustive-deps
47- } , [ isOpen , hasScanned ] ) ;
40+ const preferredDeviceDisplayName = preferredDevice ?. id === 'system-audio' ? t ( 'bluetooth.system_audio' ) : preferredDevice ?. name ;
4841
4942 const startScan = React . useCallback ( async ( ) => {
5043 try {
@@ -61,6 +54,13 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
6154 }
6255 } , [ t ] ) ;
6356
57+ // Start scanning when sheet opens
58+ useEffect ( ( ) => {
59+ if ( isOpen && ! hasScanned ) {
60+ startScan ( ) ;
61+ }
62+ } , [ isOpen , hasScanned , startScan ] ) ;
63+
6464 const handleDeviceSelect = React . useCallback (
6565 async ( device : BluetoothAudioDevice ) => {
6666 try {
@@ -222,7 +222,7 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
222222 } , [ isScanning , hasScanned , startScan , t ] ) ;
223223
224224 return (
225- < CustomBottomSheet isOpen = { isOpen } onClose = { onClose } >
225+ < CustomBottomSheet isOpen = { isOpen } onClose = { onClose } snapPoints = { [ 85 ] } minHeight = "min-h-0" >
226226 < VStack className = "flex-1 p-4" >
227227 < Heading className = "mb-4 text-lg" > { t ( 'bluetooth.select_device' ) } </ Heading >
228228
@@ -232,7 +232,7 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
232232 < HStack className = "items-center justify-between" >
233233 < VStack >
234234 < Text className = "text-sm font-medium text-neutral-900 dark:text-neutral-100" > { t ( 'bluetooth.current_selection' ) } </ Text >
235- < Text className = "text-sm text-neutral-600 dark:text-neutral-400" > { preferredDevice . name } </ Text >
235+ < Text className = "text-sm text-neutral-600 dark:text-neutral-400" > { preferredDeviceDisplayName } </ Text >
236236 </ VStack >
237237 < Button onPress = { handleClearSelection } size = { isLandscape ? 'sm' : 'xs' } variant = "outline" >
238238 < ButtonText className = { isLandscape ? '' : 'text-2xs' } > { t ( 'bluetooth.clear' ) } </ ButtonText >
@@ -255,7 +255,7 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
255255
256256 // Update preferred device manually here to ensure UI reflects it immediately
257257 // preventing race conditions with store updates
258- await setPreferredDevice ( { id : 'system-audio' , name : 'System Audio' } ) ;
258+ await setPreferredDevice ( { id : 'system-audio' , name : t ( 'bluetooth.system_audio' ) } ) ;
259259
260260 onClose ( ) ;
261261 } catch ( error ) {
@@ -277,8 +277,8 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
277277 < HStack className = "items-center" >
278278 < BluetoothIcon size = { 16 } className = "mr-2 text-primary-600" />
279279 < VStack >
280- < Text className = { `font-medium ${ preferredDevice ?. id === 'system-audio' ? 'text-primary-700 dark:text-primary-300' : 'text-neutral-900 dark:text-neutral-100' } ` } > { t ( 'bluetooth.systemAudio ' ) } </ Text >
281- < Text className = "text-xs text-neutral-500" > { t ( 'bluetooth.systemAudioDescription ' ) } </ Text >
280+ < Text className = { `font-medium ${ preferredDevice ?. id === 'system-audio' ? 'text-primary-700 dark:text-primary-300' : 'text-neutral-900 dark:text-neutral-100' } ` } > { t ( 'bluetooth.system_audio ' ) } </ Text >
281+ < Text className = "text-xs text-neutral-500" > { t ( 'bluetooth.system_audio_description ' ) } </ Text >
282282 </ VStack >
283283 </ HStack >
284284 { preferredDevice ?. id === 'system-audio' && (
@@ -316,11 +316,7 @@ export function BluetoothDeviceSelectionBottomSheet({ isOpen, onClose }: Bluetoo
316316 { bluetoothState !== State . PoweredOn && (
317317 < Box className = "mt-4 rounded-lg border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-700 dark:bg-yellow-900" >
318318 < Text className = "text-sm text-yellow-800 dark:text-yellow-200" >
319- { bluetoothState === State . PoweredOff
320- ? t ( 'bluetooth.bluetooth_disabled' )
321- : bluetoothState === State . Unauthorized
322- ? t ( 'bluetooth.bluetooth_unauthorized' )
323- : t ( 'bluetooth.bluetooth_not_ready' , { state : bluetoothState } ) }
319+ { bluetoothState === State . PoweredOff ? t ( 'bluetooth.poweredOff' ) : bluetoothState === State . Unauthorized ? t ( 'bluetooth.unauthorized' ) : t ( 'bluetooth.bluetooth_not_ready' , { state : bluetoothState } ) }
324320 </ Text >
325321 </ Box >
326322 ) }
0 commit comments