refactor: refactor code#35491
Conversation
• 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.
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
Kindly review this and inform me if any changes are needed; otherwise, proceed to merge it with the base branch. |
fix: improve DeviceProvider stability with error handling and secure context checks
Improvements & Fixes:
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