feat: audio connecting hook in bindings and RN UI#2214
Conversation
|
📝 WalkthroughWalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant Component as ParticipantLabel<br/>Component
participant Hook as useIsAudioConnecting<br/>Hook
participant Track as Audio Track
participant UI as Activity Indicator<br/>& Label
Component->>Hook: Call hook with participant
Hook->>Track: Check if audio track exists
Track-->>Hook: hasAudio = true/false
alt Audio track exists
Hook->>Track: Subscribe to mute/unmute events
Track-->>Hook: Initial muted state
Hook->>Hook: Store unmuted state in useState
Hook-->>Component: Return boolean (unmuted)
else No audio track
Hook-->>Component: Return false
end
Component->>UI: Render conditional on isAudioConnecting
alt isAudioConnecting = true
UI->>UI: Show ActivityIndicator<br/>+ "Connecting..." text
else
UI->>UI: Show label only
end
Note over Track,Hook: On track mute/unmute events
Track->>Hook: Trigger mute/unmute listener
Hook->>Hook: Update unmuted state
Component->>UI: Re-render with new state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react-bindings/src/hooks/callUtilHooks.ts`:
- Around line 55-83: The hook useIsAudioConnecting should explicitly return
boolean and must reset and track the actual active audio track so unmuted is
cleared when the first audio track changes or disappears; update
useIsAudioConnecting to declare a boolean return type, derive the current Track
object (e.g., const track = audioStream?.getAudioTracks()[0]) inside
state/effect logic, store that track reference (or its id) in state/ref and
include it in the effect dependencies, setUnmuted(false) when no track exists,
and attach/remove mute/unmute listeners to the current track so state is updated
only for that track change.
In
`@sample-apps/react-native/dogfood/src/components/AudioConnectingParticipantLabel.tsx`:
- Around line 15-30: ParticipantLabel already renders the audio-connecting
spinner so AudioConnectingParticipantLabel is duplicating indicators by calling
useIsAudioConnecting(participant) and rendering an extra ActivityIndicator; fix
this by either removing the custom badge block (the isAudioConnecting
conditional render in AudioConnectingParticipantLabel) so ParticipantLabel’s
built-in spinner is used, or add a suppression prop to ParticipantLabel (e.g.,
showAudioConnectingIndicator or disableAudioSpinner) and pass it from
AudioConnectingParticipantLabel while keeping the text badge logic; update the
useIsAudioConnecting usage accordingly to avoid duplicate listeners when you
choose suppression.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b6a22bf7-b2c6-4885-ad1f-715fae947f7a
📒 Files selected for processing (5)
packages/react-bindings/src/hooks/callUtilHooks.tspackages/react-native-sdk/src/components/Participant/ParticipantView/ParticipantLabel.tsxpackages/react-sdk/src/core/components/ParticipantView/DefaultParticipantViewUI.tsxsample-apps/react-native/dogfood/src/components/ActiveCall.tsxsample-apps/react-native/dogfood/src/components/AudioConnectingParticipantLabel.tsx
💡 Overview
📝 Implementation notes
Depends on rn-webrtc release: GetStream/react-native-webrtc#32
🎫 Ticket: https://linear.app/stream/issue/XYZ-123
📑 Docs: https://github.com/GetStream/docs-content/pull/1239
Summary by CodeRabbit