fix: Unwrap protobuf Value types in CallParticipantState.custom field#1172
fix: Unwrap protobuf Value types in CallParticipantState.custom field#1172antondokusov wants to merge 1 commit intoGetStream:mainfrom
Conversation
📝 WalkthroughWalkthroughReplaced serialization of participant custom data in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/stream_video/lib/src/sfu/data/events/sfu_event_mapper_extensions.dart (1)
244-267:⚠️ Potential issue | 🔴 CriticalUse
toProto3Json()instead ofwriteToJsonMap()for converting protobuf Struct values to native Dart types.In protobuf 6.0.0,
toProto3Json()is the official, documented API for Proto3 JSON serialization and convertingStruct/Valuetypes to native Dart equivalents (String,num,bool,List,Map<String, dynamic>). WhilewriteToJsonMap()exists and may work, it's a generic message-to-map encoder and not the intended API for this conversion.Change line 251 to:
custom: custom.toProto3Json() as Map<String, dynamic>,
07fded6 to
6fc26c4
Compare
6fc26c4 to
d747656
Compare
🎯 Goal
Fix an issue where
CallParticipantState.customfield contains protobufValuewrapper objects instead of native Dart types. This makes it difficult for developers to access custom participant data, as they need to manually unwrap eachValueobject to get the actual values.The protobuf
Structtype usesValuewrappers to represent dynamically-typed data, but when converting to the domain model, these should be unwrapped to native Dart types for easier consumption.🛠 Implementation details
Changed the conversion in
SfuParticipantExtension.toDomain()from:to:
🎨 UI Changes
N/A
🧪 Testing
This change can be tested by:
Before the fix:
After the fix:
☑️Contributor Checklist
General
☑️Reviewer Checklist
Summary by CodeRabbit