diff --git a/packages/stream_chat/lib/src/core/models/own_user.dart b/packages/stream_chat/lib/src/core/models/own_user.dart index f79d8eab7..60d152780 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -41,7 +41,8 @@ class OwnUser extends User { factory OwnUser.fromUser(User user) => OwnUser( id: user.id, role: user.role, - name: user.name, + // Using extraData value in order to not use id as name. + name: user.extraData['name'] as String?, image: user.image, createdAt: user.createdAt, updatedAt: user.updatedAt, @@ -78,7 +79,10 @@ class OwnUser extends User { OwnUser( id: id ?? this.id, role: role ?? this.role, - name: name ?? extraData?['name'] as String? ?? this.name, + name: name ?? + extraData?['name'] as String? ?? + // Using extraData value in order to not use id as name. + this.extraData['name'] as String?, image: image ?? extraData?['image'] as String? ?? this.image, banned: banned ?? this.banned, banExpires: banExpires ?? this.banExpires, @@ -103,7 +107,8 @@ class OwnUser extends User { return copyWith( id: other.id, role: other.role, - name: other.name, + // Using extraData value in order to not use id as name. + name: other.extraData['name'] as String?, image: other.image, banned: other.banned, channelMutes: other.channelMutes, diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 2c702d019..ff435f67b 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -172,7 +172,10 @@ class User extends Equatable { User( id: id ?? this.id, role: role ?? this.role, - name: name ?? extraData?['name'] as String? ?? this.name, + name: name ?? + extraData?['name'] as String? ?? + // Using extraData value in order to not use id as name. + this.extraData['name'] as String?, image: image ?? extraData?['image'] as String? ?? this.image, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, diff --git a/packages/stream_chat/test/src/client/client_test.dart b/packages/stream_chat/test/src/client/client_test.dart index 4947bc729..923d399ca 100644 --- a/packages/stream_chat/test/src/client/client_test.dart +++ b/packages/stream_chat/test/src/client/client_test.dart @@ -2514,7 +2514,7 @@ void main() { }); test( - '''setting the `currentUser` should also compute and update the unreadCounts''', + 'setting the `currentUser` should also compute and update the unreadCounts', () { final state = client.state; final initialUser = OwnUser.fromUser(user);