Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Upcoming

✅ Added

- Added teams role support for users.

## 9.8.0

✅ Added
Expand Down
5 changes: 5 additions & 0 deletions packages/stream_chat/lib/src/core/models/own_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class OwnUser extends User {
super.banExpires,
super.teams,
super.language,
super.teamsRole,
});

/// Create a new instance from json.
Expand All @@ -53,6 +54,7 @@ class OwnUser extends User {
extraData: user.extraData,
teams: user.teams,
language: user.language,
teamsRole: user.teamsRole,
);

/// Creates a copy of [OwnUser] with specified attributes overridden.
Expand All @@ -78,6 +80,7 @@ class OwnUser extends User {
int? unreadChannels,
int? unreadThreads,
String? language,
Map<String, String>? teamsRole,
}) =>
OwnUser(
id: id ?? this.id,
Expand All @@ -103,6 +106,7 @@ class OwnUser extends User {
unreadThreads: unreadThreads ?? this.unreadThreads,
blockedUserIds: blockedUserIds ?? this.blockedUserIds,
language: language ?? this.language,
teamsRole: teamsRole ?? this.teamsRole,
);

/// Returns a new [OwnUser] that is a combination of this ownUser
Expand Down Expand Up @@ -130,6 +134,7 @@ class OwnUser extends User {
blockedUserIds: other.blockedUserIds,
updatedAt: other.updatedAt,
language: other.language,
teamsRole: other.teamsRole,
);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/stream_chat/lib/src/core/models/own_user.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions packages/stream_chat/lib/src/core/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class User extends Equatable implements ComparableFieldProvider {
this.banExpires,
this.teams = const [],
this.language,
this.teamsRole,
}) :
// For backwards compatibility, set 'name', 'image' in [extraData].
extraData = {
Expand All @@ -71,6 +72,7 @@ class User extends Equatable implements ComparableFieldProvider {
'ban_expires',
'teams',
'language',
'teams_role',
];

/// User id.
Expand Down Expand Up @@ -130,6 +132,12 @@ class User extends Equatable implements ComparableFieldProvider {
@JsonKey(includeIfNull: false)
final String? language;

/// The roles for the user in the teams.
///
/// eg: `{'teamId': 'role', 'teamId2': 'role2'}`
@JsonKey(includeIfNull: false)
final Map< /*Team*/ String, /*Role*/ String>? teamsRole;

/// Map of custom user extraData.
final Map<String, Object?> extraData;

Expand Down Expand Up @@ -157,6 +165,7 @@ class User extends Equatable implements ComparableFieldProvider {
DateTime? banExpires,
List<String>? teams,
String? language,
Map<String, String>? teamsRole,
}) =>
User(
id: id ?? this.id,
Expand All @@ -175,6 +184,7 @@ class User extends Equatable implements ComparableFieldProvider {
banExpires: banExpires ?? this.banExpires,
teams: teams ?? this.teams,
language: language ?? this.language,
teamsRole: teamsRole ?? this.teamsRole,
);

@override
Expand All @@ -188,6 +198,7 @@ class User extends Equatable implements ComparableFieldProvider {
banExpires,
teams,
language,
teamsRole,
];

@override
Expand Down
4 changes: 4 additions & 0 deletions packages/stream_chat/lib/src/core/models/user.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/stream_chat_persistence/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Upcoming

- Added support for `User.teamsRole` field.

## 9.8.0

- Added `pinnedAt` and `archivedAt` fields on `Member`.
Expand Down
Loading