@graineai/inapp-react-native 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,9 +66,11 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
|
|
|
66
66
|
});
|
|
67
67
|
}, [client, post]);
|
|
68
68
|
useEffect(() => {
|
|
69
|
-
if (ready)
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (!ready)
|
|
70
|
+
return;
|
|
71
|
+
pushContext();
|
|
72
|
+
return client.on("screen", () => pushContext());
|
|
73
|
+
}, [client, ready, pushContext]);
|
|
72
74
|
const beginCall = useCallback(async () => {
|
|
73
75
|
if (client.isConnected) {
|
|
74
76
|
console.warn("[graine] The provider has its own connection open while GraineVoiceLauncher " +
|
|
@@ -116,7 +118,8 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
|
|
|
116
118
|
case "graine:ready":
|
|
117
119
|
setReady(true);
|
|
118
120
|
pushContext();
|
|
119
|
-
if (autoStart && !startedRef.current) {
|
|
121
|
+
if ((autoStart || pendingStartRef.current) && !startedRef.current) {
|
|
122
|
+
pendingStartRef.current = false;
|
|
120
123
|
startedRef.current = true;
|
|
121
124
|
void beginCall();
|
|
122
125
|
}
|
|
@@ -156,14 +159,20 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
|
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
}, [autoStart, beginCall, client, onCaption, onCallState, onMicDenied, onTransport, onError, onEnded, post, pushContext]);
|
|
162
|
+
const pendingStartRef = useRef(false);
|
|
159
163
|
const api = {
|
|
160
164
|
connected,
|
|
161
165
|
connecting,
|
|
162
166
|
muted,
|
|
167
|
+
ready: !!voiceAgentId && ready,
|
|
163
168
|
start: useCallback(() => {
|
|
164
169
|
setConnecting(true);
|
|
170
|
+
if (!ready) {
|
|
171
|
+
pendingStartRef.current = true;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
165
174
|
void beginCall();
|
|
166
|
-
}, [beginCall]),
|
|
175
|
+
}, [beginCall, ready]),
|
|
167
176
|
end: useCallback(() => post({ type: "graine:end-call" }), [post]),
|
|
168
177
|
setMuted: useCallback((m) => {
|
|
169
178
|
setMutedState(m);
|
package/package.json
CHANGED