@graineai/inapp-react-native 0.17.0 → 0.18.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.
|
@@ -116,7 +116,8 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
|
|
|
116
116
|
case "graine:ready":
|
|
117
117
|
setReady(true);
|
|
118
118
|
pushContext();
|
|
119
|
-
if (autoStart && !startedRef.current) {
|
|
119
|
+
if ((autoStart || pendingStartRef.current) && !startedRef.current) {
|
|
120
|
+
pendingStartRef.current = false;
|
|
120
121
|
startedRef.current = true;
|
|
121
122
|
void beginCall();
|
|
122
123
|
}
|
|
@@ -156,14 +157,20 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
}, [autoStart, beginCall, client, onCaption, onCallState, onMicDenied, onTransport, onError, onEnded, post, pushContext]);
|
|
160
|
+
const pendingStartRef = useRef(false);
|
|
159
161
|
const api = {
|
|
160
162
|
connected,
|
|
161
163
|
connecting,
|
|
162
164
|
muted,
|
|
165
|
+
ready: !!voiceAgentId && ready,
|
|
163
166
|
start: useCallback(() => {
|
|
164
167
|
setConnecting(true);
|
|
168
|
+
if (!ready) {
|
|
169
|
+
pendingStartRef.current = true;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
165
172
|
void beginCall();
|
|
166
|
-
}, [beginCall]),
|
|
173
|
+
}, [beginCall, ready]),
|
|
167
174
|
end: useCallback(() => post({ type: "graine:end-call" }), [post]),
|
|
168
175
|
setMuted: useCallback((m) => {
|
|
169
176
|
setMutedState(m);
|
package/package.json
CHANGED