fix(audio-message): iOS regression

This commit is contained in:
devthejo 2026-01-16 18:09:52 +01:00
parent 8678263935
commit 5951f36291
No known key found for this signature in database
GPG key ID: 00CCA7A92B1D5351

View file

@ -339,8 +339,18 @@ export default function useVoiceRecorder() {
// Cancel any pending start when the app transitions away from active. // Cancel any pending start when the app transitions away from active.
// This prevents a stalled promise from completing later and starting recording unexpectedly. // This prevents a stalled promise from completing later and starting recording unexpectedly.
const sub = AppState.addEventListener("change", (state) => { const sub = AppState.addEventListener("change", (state) => {
if (state !== "active") { if (Platform.OS === "android") {
startAttemptRef.current += 1; // Android: cancel on any transition away from active (prevents delayed auto-start).
if (state !== "active") {
startAttemptRef.current += 1;
}
} else {
// iOS: permission prompts commonly put the app into `inactive` temporarily.
// Cancelling on `inactive` breaks first-run permission flow.
// Only cancel when truly backgrounded.
if (state === "background") {
startAttemptRef.current += 1;
}
} }
}); });
return () => { return () => {