mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
* feat(mobile): polish press feedback, sheet motion, states, spacing and layout jumps Every control presses and disables the same way, with one haptic rule. Sheets follow the finger and settle without bounce, pickers stack instead of swapping, and screens slide over a dimmed, shifted parent. Loading, empty, error and offline states share one view with plain-language errors, rows and labels line up on one grid, and screens stop jumping as data arrives. * fix(mobile): settle voice, tasks and accounts states; keep host snapshot current Voice settings with no paired desktop shows the connect state instead of loading forever. A failed task settings read after a successful probe retries hydration. The shared host-list snapshot drops on invalidation and ignores stale passes. Accounts shows a re-pair state on auth failure, and busy action-sheet rows keep their disabled state for screen readers.
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { useEffect, useMemo, useState } from 'react'
|
|
import { useRouter } from 'expo-router'
|
|
import { loadHosts, peekHosts } from '../src/transport/host-store'
|
|
import type { HostProfile } from '../src/transport/types'
|
|
import { useFocusedSettingsHostClients } from '../src/transport/settings-host-client-connections'
|
|
import VoiceSettingsScreen from '../src/settings/voice-settings-screen'
|
|
import { nativeVoiceSettingsOperations } from '../src/settings/native-voice-settings-operations'
|
|
|
|
export default function NativeVoiceSettingsRoute() {
|
|
const router = useRouter()
|
|
// Null until the first read, so a paired phone never flashes "connect a desktop".
|
|
const [hosts, setHosts] = useState<HostProfile[] | null>(() => peekHosts())
|
|
useEffect(() => {
|
|
void loadHosts().then(setHosts)
|
|
}, [])
|
|
const hostIds = useMemo(() => (hosts ?? []).map((host) => host.id), [hosts])
|
|
const { clients, focused } = useFocusedSettingsHostClients(hostIds)
|
|
const connected = clients.find((entry) => entry.state === 'connected')
|
|
const client = connected?.client ?? null
|
|
const connecting =
|
|
!connected &&
|
|
(hosts === null ||
|
|
(hosts.length > 0 &&
|
|
(clients.length === 0 ||
|
|
clients.some(
|
|
(entry) => entry.state !== 'disconnected' && entry.state !== 'auth-failed'
|
|
))))
|
|
// Keep the last desktop through reconnects; a different desktop remounts the screen.
|
|
const [screenHostId, setScreenHostId] = useState(connected?.hostId)
|
|
if (connected && connected.hostId !== screenHostId) {
|
|
setScreenHostId(connected.hostId)
|
|
}
|
|
const operations = useMemo(
|
|
() => (client ? nativeVoiceSettingsOperations(client) : null),
|
|
[client]
|
|
)
|
|
return (
|
|
// Remount per desktop so a late reply from the previous one cannot land on this screen.
|
|
<VoiceSettingsScreen
|
|
key={screenHostId}
|
|
operations={operations}
|
|
connecting={connecting}
|
|
focused={focused}
|
|
onBack={() => router.back()}
|
|
/>
|
|
)
|
|
}
|