diff --git a/src/components/playground/PhoneSimulator.tsx b/src/components/playground/PhoneSimulator.tsx index f413721..e66bba8 100644 --- a/src/components/playground/PhoneSimulator.tsx +++ b/src/components/playground/PhoneSimulator.tsx @@ -17,11 +17,12 @@ import { useToast } from "@/components/toast/ToasterProvider"; export interface PhoneSimulatorProps { onConnect: () => void; + onDisconnect: () => void; phoneMode?: "normal" | "capture"; onCapture?: (image: File) => void; } -export function PhoneSimulator({ onConnect, phoneMode = "normal", onCapture }: PhoneSimulatorProps) { +export function PhoneSimulator({ onConnect, onDisconnect, phoneMode = "normal", onCapture }: PhoneSimulatorProps) { const { config, setUserSettings } = useConfig(); const { setToastMessage } = useToast(); const room = useRoomContext(); @@ -41,7 +42,6 @@ export function PhoneSimulator({ onConnect, phoneMode = "normal", onCapture }: P const [processingSource, setProcessingSource] = useState< "camera" | "upload" | null >(null); - const [lastVoiceChangeAt, setLastVoiceChangeAt] = useState(null); useEffect(() => { const voiceAttr = config.settings.attributes?.find(a => a.key === "voice"); @@ -169,7 +169,7 @@ export function PhoneSimulator({ onConnect, phoneMode = "normal", onCapture }: P }; const handleDisconnect = () => { - room.disconnect(); + onDisconnect(); }; const handleCapture = async () => { @@ -328,8 +328,7 @@ export function PhoneSimulator({ onConnect, phoneMode = "normal", onCapture }: P newSettings.attributes = attributes; setUserSettings(newSettings); setCurrentVoiceId(voiceId); - setLastVoiceChangeAt(Date.now()); - setTimeout(() => setShowVoiceMenu(false), 100); + setTimeout(() => setShowVoiceMenu(false), 200); }; const handleVoiceMenuToggle = (e: React.MouseEvent) => { @@ -360,9 +359,6 @@ export function PhoneSimulator({ onConnect, phoneMode = "normal", onCapture }: P e.stopPropagation(); // Guard against accidental call when just changing voice if (showVoiceMenu) return; - if (lastVoiceChangeAt && Date.now() - lastVoiceChangeAt < 400) { - return; - } onConnect(); }} disabled={showVoiceMenu} diff --git a/src/components/playground/Playground.tsx b/src/components/playground/Playground.tsx index a10fedb..d230fb1 100644 --- a/src/components/playground/Playground.tsx +++ b/src/components/playground/Playground.tsx @@ -597,6 +597,7 @@ export default function Playground({ > onConnect(true)} + onDisconnect={() => onConnect(false)} phoneMode={phoneMode} onCapture={async (content: File) => { if (localParticipant) { @@ -669,6 +670,7 @@ export default function Playground({ > onConnect(true)} + onDisconnect={() => onConnect(false)} phoneMode={phoneMode} onCapture={async (content: File) => { if (localParticipant) {