Skip to content

Commit

Permalink
add custom data to call participants (#560)
Browse files Browse the repository at this point in the history
* add custom data to call participants

* changelog
  • Loading branch information
Brazol authored Dec 21, 2023
1 parent 1b90a73 commit 5ccc165
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ mixin StateCoordinatorMixin on StateNotifier<CallState> {
userId: e.userId,
role: e.role,
name: e.name,
custom: e.custom,
sessionId: e.sessionId,
trackIdPrefix: e.trackIdPrefix,
image: e.image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ extension on CallMetadata {
userId: userId,
role: member?.role ?? user?.role ?? '',
name: user?.name ?? '',
custom: user?.custom ?? {},
image: user?.image ?? '',
sessionId: '',
trackIdPrefix: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ mixin StateSfuMixin on StateNotifier<CallState> {
userId: aParticipant.userId,
role: existingRole,
name: aParticipant.userName.ifEmpty(() => existingName),
custom: aParticipant.custom,
image: aParticipant.userImage.ifEmpty(() => existingImage),
sessionId: aParticipant.sessionId,
trackIdPrefix: aParticipant.trackLookupPrefix,
Expand Down Expand Up @@ -208,6 +209,7 @@ mixin StateSfuMixin on StateNotifier<CallState> {
userId: event.participant.userId,
role: '',
name: event.participant.userName,
custom: event.participant.custom,
image: event.participant.userImage,
sessionId: event.participant.sessionId,
trackIdPrefix: event.participant.trackLookupPrefix,
Expand Down
1 change: 1 addition & 0 deletions packages/stream_video/lib/src/call_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ extension on CallMetadata {
userId: userId,
role: member?.role ?? user?.role ?? '',
name: user?.name ?? '',
custom: user?.custom ?? {},
image: user?.image ?? '',
sessionId: '',
trackIdPrefix: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CallParticipantState
required this.userId,
required this.role,
required this.name,
required this.custom,
this.image,
required this.sessionId,
required this.trackIdPrefix,
Expand All @@ -34,6 +35,7 @@ class CallParticipantState
final String userId;
final String role;
final String name;
final Map<String, Object?> custom;
final String? image;
final String sessionId;
final String trackIdPrefix;
Expand All @@ -54,6 +56,7 @@ class CallParticipantState
String? userId,
String? role,
String? name,
Map<String, Object?>? custom,
String? image,
String? sessionId,
String? trackIdPrefix,
Expand All @@ -72,6 +75,7 @@ class CallParticipantState
userId: userId ?? this.userId,
role: role ?? this.role,
name: name ?? this.name,
custom: custom ?? this.custom,
image: image ?? this.image,
sessionId: sessionId ?? this.sessionId,
trackIdPrefix: trackIdPrefix ?? this.trackIdPrefix,
Expand Down Expand Up @@ -123,6 +127,7 @@ class CallParticipantState
userId,
role,
name,
custom,
image,
sessionId,
trackIdPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ extension SfuParticipantExtension on sfu_models.Participant {
userName: name,
userImage: image,
sessionId: sessionId,
custom: custom.fields,
publishedTracks: publishedTracks
.map(
(track) => track.toDomain(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ enum SfuGoAwayReason {
String toString() {
return name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SfuParticipant with EquatableMixin {
required this.userName,
required this.userImage,
required this.sessionId,
required this.custom,
required this.publishedTracks,
required this.joinedAt,
required this.trackLookupPrefix,
Expand All @@ -23,6 +24,7 @@ class SfuParticipant with EquatableMixin {
final String userName;
final String userImage;
final String sessionId;
final Map<String, Object?> custom;
final List<SfuTrackType> publishedTracks;
final DateTime joinedAt;
final String trackLookupPrefix;
Expand All @@ -37,6 +39,7 @@ class SfuParticipant with EquatableMixin {
String? userName,
String? userImage,
String? sessionId,
Map<String, Object?>? custom,
List<SfuTrackType>? publishedTracks,
DateTime? joinedAt,
String? trackLookupPrefix,
Expand All @@ -51,6 +54,7 @@ class SfuParticipant with EquatableMixin {
userName: userId ?? this.userName,
userImage: userId ?? this.userImage,
sessionId: sessionId ?? this.sessionId,
custom: custom ?? this.custom,
publishedTracks: publishedTracks ?? this.publishedTracks,
joinedAt: joinedAt ?? this.joinedAt,
trackLookupPrefix: trackLookupPrefix ?? this.trackLookupPrefix,
Expand Down Expand Up @@ -78,6 +82,7 @@ class SfuParticipant with EquatableMixin {
userName,
userImage,
sessionId,
custom,
publishedTracks,
joinedAt,
trackLookupPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void main() {
name: 'A',
userId: '1',
sessionId: '1',
custom: const {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {
Expand All @@ -33,6 +34,7 @@ void main() {
name: 'B',
userId: '2',
sessionId: '2',
custom: const {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {
Expand All @@ -53,6 +55,7 @@ void main() {
name: 'C',
userId: '3',
sessionId: '3',
custom: {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {},
Expand All @@ -69,6 +72,7 @@ void main() {
name: 'D',
userId: '4',
sessionId: '4',
custom: const {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {SfuTrackType.audio: TrackState.remote()},
Expand All @@ -85,6 +89,7 @@ void main() {
name: 'E',
userId: '5',
sessionId: '5',
custom: const {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {SfuTrackType.screenShare: TrackState.remote()},
Expand All @@ -101,6 +106,7 @@ void main() {
name: 'F',
userId: '6',
sessionId: '6',
custom: const {},
role: 'admin',
trackIdPrefix: '123',
publishedTracks: {
Expand Down
4 changes: 4 additions & 0 deletions packages/stream_video_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Upcoming

* Added `custom` field to `CallParticipantState` with custom user data.

## 0.3.1

* Important: Fixes crash for CallKit on iOS.
Expand Down

0 comments on commit 5ccc165

Please sign in to comment.