refactor: rename conversation to voice conversation throughout stack
This commit is contained in:
@@ -2,6 +2,10 @@ import { createContext, useContext, useState, ReactNode, useCallback, useEffect,
|
||||
import { useSpeechmaticsAudio } from "@/hooks/use-speechmatics-audio";
|
||||
import type { SessionState } from "@/stores/session-store";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { randomUUID } from "expo-crypto";
|
||||
|
||||
const VOICE_CONVERSATION_ID_STORAGE_KEY = "@paseo:voice-conversation-id";
|
||||
|
||||
interface RealtimeContextValue {
|
||||
isRealtimeMode: boolean;
|
||||
@@ -160,7 +164,16 @@ export function RealtimeProvider({ children }: RealtimeProviderProps) {
|
||||
console.log("[Realtime] Mode enabled");
|
||||
|
||||
if (session?.client) {
|
||||
await session.client.setRealtimeMode(true);
|
||||
let voiceConversationId =
|
||||
(await AsyncStorage.getItem(VOICE_CONVERSATION_ID_STORAGE_KEY)) ?? null;
|
||||
if (!voiceConversationId) {
|
||||
voiceConversationId = randomUUID();
|
||||
await AsyncStorage.setItem(
|
||||
VOICE_CONVERSATION_ID_STORAGE_KEY,
|
||||
voiceConversationId
|
||||
);
|
||||
}
|
||||
await session.client.setVoiceConversation(true, voiceConversationId);
|
||||
} else {
|
||||
console.warn("[Realtime] setRealtimeMode skipped: daemon unavailable");
|
||||
}
|
||||
@@ -183,7 +196,7 @@ export function RealtimeProvider({ children }: RealtimeProviderProps) {
|
||||
console.log("[Realtime] Mode disabled");
|
||||
|
||||
if (session?.client) {
|
||||
await session.client.setRealtimeMode(false);
|
||||
await session.client.setVoiceConversation(false);
|
||||
} else {
|
||||
console.warn("[Realtime] setRealtimeMode skipped: daemon unavailable");
|
||||
}
|
||||
|
||||
@@ -803,10 +803,7 @@ export function SessionProvider({
|
||||
{ serverId }
|
||||
);
|
||||
void client
|
||||
.loadConversation(client.currentConversationId ?? undefined)
|
||||
.catch((error) => {
|
||||
console.warn("[Session] session_state request failed:", error);
|
||||
});
|
||||
.requestSessionState();
|
||||
|
||||
if (sessionStateTimeoutRef.current) {
|
||||
clearTimeout(sessionStateTimeoutRef.current);
|
||||
@@ -2242,11 +2239,11 @@ export function SessionProvider({
|
||||
console.warn("[Session] refreshSession skipped: daemon unavailable");
|
||||
return;
|
||||
}
|
||||
void client
|
||||
.loadConversation(client.currentConversationId ?? undefined)
|
||||
.catch((error) => {
|
||||
console.error("[Session] Failed to refresh session:", error);
|
||||
});
|
||||
try {
|
||||
client.requestSessionState();
|
||||
} catch (error: any) {
|
||||
console.error("[Session] Failed to refresh session:", error);
|
||||
}
|
||||
}, [client, serverId]);
|
||||
|
||||
// Cleanup on unmount
|
||||
|
||||
Reference in New Issue
Block a user