From c5782e0275c2b03e1894ca3634b1461a42e57c7f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 27 Jul 2021 16:47:24 +0530 Subject: [PATCH] chore(llc): re-generate model classes Signed-off-by: xsahil03x --- .../lib/src/core/models/message.g.dart | 2 +- .../lib/src/core/models/own_user.dart | 7 ++---- .../lib/src/core/models/own_user.g.dart | 1 + .../stream_chat/lib/src/core/models/user.dart | 23 ++----------------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index 8ad1b3e1..5fb559f0 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -110,6 +110,6 @@ Map _$MessageToJson(Message instance) { val['pinned_by'] = readonly(instance.pinnedBy); val['extra_data'] = instance.extraData; writeNotNull('deleted_at', readonly(instance.deletedAt)); - val['i18n'] = instance.i18n; + writeNotNull('i18n', readonly(instance.i18n)); return val; } 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 0eada8d0..116a2f84 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -27,7 +27,7 @@ class OwnUser extends User { Map extraData = const {}, bool banned = false, List teams = const [], - String? language, + String language = 'en', }) : super( id: id, role: role, @@ -99,10 +99,7 @@ class OwnUser extends User { /// Returns a new [OwnUser] that is a combination of this ownUser /// and the given [other] ownUser. OwnUser merge(OwnUser? other) { - if (other == null) { - return this; - } - + if (other == null) return this; return copyWith( banned: other.banned, channelMutes: other.channelMutes, diff --git a/packages/stream_chat/lib/src/core/models/own_user.g.dart b/packages/stream_chat/lib/src/core/models/own_user.g.dart index 465faff2..5d80cc1c 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.g.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.g.dart @@ -39,5 +39,6 @@ OwnUser _$OwnUserFromJson(Map json) { teams: (json['teams'] as List?)?.map((e) => e as String).toList() ?? [], + language: json['language'] as String? ?? 'en', ); } diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 12ab162d..2cdb6dd6 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -88,10 +88,7 @@ class User extends Equatable { /// /// Defaults to 'en'. @JsonKey(defaultValue: 'en') - final String? language; - - @override - int get hashCode => id.hashCode; + final String language; /// Shortcut for user name String get name { @@ -106,11 +103,6 @@ class User extends Equatable { static List? toIds(List? users) => users?.map((u) => u.id).toList(); - @override - bool operator ==(Object other) => - identical(this, other) || - other is User && runtimeType == other.runtimeType && id == other.id; - /// Serialize to json Map toJson() => Serializer.moveFromExtraDataToRoot( _$UserToJson(this), @@ -143,16 +135,5 @@ class User extends Equatable { ); @override - List get props => [ - id, - role, - teams, - createdAt, - updatedAt, - lastActive, - online, - banned, - extraData, - language, - ]; + List get props => [id]; }