fix(web): let the list dictation run in the iOS home-screen app
The floating button's commit made the multi-item dictation go through canDictate(), which treats an iOS home-screen app as unsupported. That rule belongs to the input's microphone, which dictates without asking for the microphone first; the multi-item flow asks with getUserMedia and works there, so both the empty list's card and the FAB said the browser could not dictate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { splitDictation } from '@/lib/natural-input/dictation'
|
||||
import {
|
||||
canDictate,
|
||||
getSpeechRecognition,
|
||||
type SpeechRecognitionLike,
|
||||
} from '@/lib/speech-recognition'
|
||||
import { getSpeechRecognition, type SpeechRecognitionLike } from '@/lib/speech-recognition'
|
||||
|
||||
export const DICTATION_MESSAGES = {
|
||||
denied: 'No tenemos permiso para usar el micrófono. Habilítalo en los ajustes del navegador.',
|
||||
@@ -55,7 +51,7 @@ type UseMicrophoneDictationOptions = {
|
||||
* capture. Unmounting aborts the recognition.
|
||||
*/
|
||||
export function useMicrophoneDictation({ onPhrases, onError }: UseMicrophoneDictationOptions) {
|
||||
const [supported] = useState(() => canDictate())
|
||||
const [supported] = useState(() => getSpeechRecognition() !== null)
|
||||
const [status, setStatus] = useState<DictationStatus>('idle')
|
||||
// What has been heard so far, shown while listening.
|
||||
const [heard, setHeard] = useState('')
|
||||
@@ -72,7 +68,7 @@ export function useMicrophoneDictation({ onPhrases, onError }: UseMicrophoneDict
|
||||
const start = useCallback(() => {
|
||||
if (endRef.current) return
|
||||
|
||||
const SpeechRecognition = canDictate() ? getSpeechRecognition() : null
|
||||
const SpeechRecognition = getSpeechRecognition()
|
||||
if (!SpeechRecognition) {
|
||||
callbacksRef.current.onError(DICTATION_MESSAGES.unsupported)
|
||||
return
|
||||
|
||||
@@ -34,9 +34,11 @@ export function isIosStandalone(): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this browser can dictate on its own. An iOS home-screen app exposes
|
||||
* `webkitSpeechRecognition` but it does not work there, so it counts as unsupported
|
||||
* (the keyboard's own dictation still works).
|
||||
* Whether this browser can dictate a phrase without asking for the microphone first
|
||||
* (the input's microphone). An iOS home-screen app exposes `webkitSpeechRecognition`
|
||||
* but that flow does not work there, so it counts as unsupported (the keyboard's own
|
||||
* dictation still works). Dictating several items does work there, because it asks
|
||||
* for the microphone with `getUserMedia` first, so it checks `getSpeechRecognition()`.
|
||||
*/
|
||||
export function canDictate(): boolean {
|
||||
if (typeof window === 'undefined' || isIosStandalone()) return false
|
||||
|
||||
Reference in New Issue
Block a user