chore: Add language to OwnUser

This commit is contained in:
groovinchip
2021-07-22 11:08:10 -04:00
parent f109a47909
commit 4f768024c6
4 changed files with 16 additions and 1 deletions
@@ -27,6 +27,7 @@ class OwnUser extends User {
Map<String, Object?> extraData = const {}, Map<String, Object?> extraData = const {},
bool banned = false, bool banned = false,
List<String> teams = const [], List<String> teams = const [],
String? language,
}) : super( }) : super(
id: id, id: id,
role: role, role: role,
@@ -37,6 +38,7 @@ class OwnUser extends User {
extraData: extraData, extraData: extraData,
banned: banned, banned: banned,
teams: teams, teams: teams,
language: language,
); );
/// Create a new instance from a json /// Create a new instance from a json
@@ -54,6 +56,7 @@ class OwnUser extends User {
banned: user.banned, banned: user.banned,
extraData: user.extraData, extraData: user.extraData,
teams: user.teams, teams: user.teams,
language: user.language,
); );
/// Creates a copy of [OwnUser] with specified attributes overridden. /// Creates a copy of [OwnUser] with specified attributes overridden.
@@ -73,6 +76,7 @@ class OwnUser extends User {
List<Mute>? mutes, List<Mute>? mutes,
int? totalUnreadCount, int? totalUnreadCount,
int? unreadChannels, int? unreadChannels,
String? language,
}) => }) =>
OwnUser( OwnUser(
id: id ?? this.id, id: id ?? this.id,
@@ -89,6 +93,7 @@ class OwnUser extends User {
mutes: mutes ?? this.mutes, mutes: mutes ?? this.mutes,
totalUnreadCount: totalUnreadCount ?? this.totalUnreadCount, totalUnreadCount: totalUnreadCount ?? this.totalUnreadCount,
unreadChannels: unreadChannels ?? this.unreadChannels, unreadChannels: unreadChannels ?? this.unreadChannels,
language: language ?? this.language,
); );
/// Returns a new [OwnUser] that is a combination of this ownUser /// Returns a new [OwnUser] that is a combination of this ownUser
@@ -113,6 +118,7 @@ class OwnUser extends User {
totalUnreadCount: other.totalUnreadCount, totalUnreadCount: other.totalUnreadCount,
unreadChannels: other.unreadChannels, unreadChannels: other.unreadChannels,
updatedAt: other.updatedAt, updatedAt: other.updatedAt,
language: other.language,
); );
} }
@@ -37,6 +37,7 @@ class User extends Equatable {
'online', 'online',
'banned', 'banned',
'teams', 'teams',
'language',
]; ];
/// User id /// User id
@@ -126,6 +127,7 @@ class User extends Equatable {
Map<String, Object?>? extraData, Map<String, Object?>? extraData,
bool? banned, bool? banned,
List<String>? teams, List<String>? teams,
String? language,
}) => }) =>
User( User(
id: id ?? this.id, id: id ?? this.id,
@@ -137,6 +139,7 @@ class User extends Equatable {
extraData: extraData ?? this.extraData, extraData: extraData ?? this.extraData,
banned: banned ?? this.banned, banned: banned ?? this.banned,
teams: teams ?? this.teams, teams: teams ?? this.teams,
language: language ?? this.language,
); );
@override @override
@@ -150,5 +153,6 @@ class User extends Equatable {
online, online,
banned, banned,
extraData, extraData,
language,
]; ];
} }
@@ -24,11 +24,15 @@ void main() async {
/// Please see the following for more information: /// Please see the following for more information:
/// https://getstream.io/chat/docs/ios_user_setup_and_tokens/ /// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
await client.connectUser( await client.connectUser(
User(id: 'super-band-9'), User(id: 'super-band-9', language: 'fr'),
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.' 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.'
'0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A', '0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A',
); );
client.on().listen((e) {
print('e.user.language ${e.me?.language}');
});
final channel = client.channel('messaging', id: 'godevs'); final channel = client.channel('messaging', id: 'godevs');
await channel.watch(); await channel.watch();
@@ -29,6 +29,7 @@ class MessageText extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
//print(StreamChat.of(context).user);
final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\n\n'); final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\n\n');
final themeData = Theme.of(context); final themeData = Theme.of(context);