Skip to content

Refactor: Extract track streaming status to custom hook#17171

Open
Aashuti-Tech-Trek wants to merge 1 commit intojitsi:masterfrom
Aashuti-Tech-Trek:feat/useTrackStreamingStatus
Open

Refactor: Extract track streaming status to custom hook#17171
Aashuti-Tech-Trek wants to merge 1 commit intojitsi:masterfrom
Aashuti-Tech-Trek:feat/useTrackStreamingStatus

Conversation

@Aashuti-Tech-Trek
Copy link

This PR addresses two TODO comments in react/features/connection-indicator/components/web/ConnectionIndicatorIcon.tsx by extracting the track streaming status listeners into a clean, reusable React custom hook. Currently, the ConnectionIndicatorIcon component manually listens to JitsiTrackEvents. TRACK_STREAMING_STATUS_CHANGED and dispatches to the Redux store via an inline useEffect. The original authors explicitly noted this should be rewritten into a standalone hook that maintains a local status reference.

Changes made

  • Created a new useTrackStreamingStatus(track) custom hook inside react/features/connection-indicator/hooks.ts .
  • Refactored ConnectionIndicatorIcon.tsx to utilize the new hook, drastically simplifying the component's internal logic and reducing its dependency on manual event listener teardowns.
  • Verified that the UI continues to successfully display the correct real-time track stats with zero visual regressions.

Why this change

  • Implements a requested architectural cleanup left behind by previous maintainers (TODO).
  • Reduces technical debt and component complexity.
  • Promotes reusability for any future components that need to respond to stream status changes.
  • Impact Internal refactor only.
  • No visual UI changes.
  • npm run tsc:web passes with 0 errors.

Related Issue Fixes #17170

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Extract track streaming status listener into a reusable custom hook (Technical Debt)

2 participants