Skip to content

refactor: refactor code#35491

Open
Vruddhi18 wants to merge 2 commits into
RocketChat:developfrom
Vruddhi18:Vruddhi18-updates
Open

refactor: refactor code#35491
Vruddhi18 wants to merge 2 commits into
RocketChat:developfrom
Vruddhi18:Vruddhi18-updates

Conversation

@Vruddhi18
Copy link
Copy Markdown

fix: improve DeviceProvider stability with error handling and secure context checks

Improvements & Fixes:

  • Ensured useEffectEvent is retained – Maintains compatibility with other files in the project.
  • Fixed isSecureContext check – Prevents crashes in environments where isSecureContext is undefined.
  • Added error handling for media device selection:
  • Wrapped .setSinkId() in a catch block to prevent runtime errors if setting the output device fails.
  • Wrapped .enumerateDevices() in a catch block to log errors without breaking execution.
  • Handled missing device labels – Ensures all devices have a valid label (fallback to 'Unknown Device' if empty).
  • Preserved existing structure and logic – Minimal changes to maintain smooth integration with other files.

Checklist

✅ I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc
✅ I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat
✅ Lint and unit tests pass locally with my changes

	•	Replaced useEffectEvent with a direct function for setting the output device.
	•	Added error handling for .setSinkId() and .enumerateDevices().
	•	Fixed isSecureContext check to avoid undefined reference errors.
	•	Ensured devices without labels default to 'Unknown Device'.
	•	Optimized useMemo to prevent unnecessary re-renders.
	•	Improved stability when handling media device changes.
…d secure context validation

# Improvements & Fixes:
✅ Ensured useEffectEvent is retained – Maintains compatibility with other files in the project.

✅ Fixed isSecureContext check – Prevents crashes in environments where isSecureContext is undefined.

✅ Added error handling for media device selection:

✅Wrapped .setSinkId() in a catch block to prevent runtime errors if setting the output device fails.
✅ Wrapped .enumerateDevices() in a catch block to log errors without breaking execution.

✅ Handled missing device labels – Ensures all devices have a valid label (fallback to 'Unknown Device' if empty).

✅ Preserved existing structure and logic – Minimal changes to maintain smooth integration with other files.
@Vruddhi18 Vruddhi18 requested a review from a team as a code owner March 13, 2025 18:52
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 13, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 13, 2025

⚠️ No Changeset found

Latest commit: 0059442

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Vruddhi18 Vruddhi18 changed the title Improve DeviceProvider stability with error handling and secure context checks refactor: refactor code Mar 13, 2025
@Vruddhi18
Copy link
Copy Markdown
Author

Kindly review this and inform me if any changes are needed; otherwise, proceed to merge it with the base branch.

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.

2 participants