fix: generated new models, fixed reactions
This commit is contained in:
@@ -10,7 +10,7 @@ SyncResponse _$SyncResponseFromJson(Map<String, dynamic> json) {
|
||||
return SyncResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..events = (json['events'] as List<dynamic>?)
|
||||
?.map((e) => Event.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Event.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ TranslateMessageResponse _$TranslateMessageResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: TranslatedMessage.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: TranslatedMessage.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
QueryMembersResponse _$QueryMembersResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -44,7 +44,7 @@ QueryUsersResponse _$QueryUsersResponseFromJson(Map<String, dynamic> json) {
|
||||
return QueryUsersResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..users = (json['users'] as List<dynamic>?)
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ QueryReactionsResponse _$QueryReactionsResponseFromJson(
|
||||
return QueryReactionsResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..reactions = (json['reactions'] as List<dynamic>?)
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ QueryRepliesResponse _$QueryRepliesResponseFromJson(Map<String, dynamic> json) {
|
||||
return QueryRepliesResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..messages = (json['messages'] as List<dynamic>?)
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ SendReactionResponse _$SendReactionResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?)
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>)
|
||||
..reaction = json['reaction'] == null
|
||||
? null
|
||||
: Reaction.fromJson(json['reaction'] as Map<String, dynamic>?);
|
||||
: Reaction.fromJson(json['reaction'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
ConnectGuestUserResponse _$ConnectGuestUserResponseFromJson(
|
||||
@@ -103,14 +103,14 @@ ConnectGuestUserResponse _$ConnectGuestUserResponseFromJson(
|
||||
..accessToken = json['access_token'] as String?
|
||||
..user = json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>?);
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
UpdateUsersResponse _$UpdateUsersResponseFromJson(Map<String, dynamic> json) {
|
||||
return UpdateUsersResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..users = (json['users'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, User.fromJson(e as Map<String, dynamic>?)),
|
||||
(k, e) => MapEntry(k, User.fromJson(e as Map<String, dynamic>)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ UpdateMessageResponse _$UpdateMessageResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
SendMessageResponse _$SendMessageResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -128,7 +128,7 @@ SendMessageResponse _$SendMessageResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
GetMessageResponse _$GetMessageResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -136,10 +136,10 @@ GetMessageResponse _$GetMessageResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?)
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>)
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?);
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
SearchMessagesResponse _$SearchMessagesResponseFromJson(
|
||||
@@ -156,7 +156,7 @@ GetMessagesByIdResponse _$GetMessagesByIdResponseFromJson(
|
||||
return GetMessagesByIdResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..messages = (json['messages'] as List<dynamic>?)
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ UpdateChannelResponse _$UpdateChannelResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson(
|
||||
@@ -181,7 +181,7 @@ PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
@@ -193,13 +193,13 @@ InviteMembersResponse _$InviteMembersResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
RemoveMembersResponse _$RemoveMembersResponseFromJson(
|
||||
@@ -208,13 +208,13 @@ RemoveMembersResponse _$RemoveMembersResponseFromJson(
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
SendActionResponse _$SendActionResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -222,7 +222,7 @@ SendActionResponse _$SendActionResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
AddMembersResponse _$AddMembersResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -230,13 +230,13 @@ AddMembersResponse _$AddMembersResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
AcceptInviteResponse _$AcceptInviteResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -244,13 +244,13 @@ AcceptInviteResponse _$AcceptInviteResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
RejectInviteResponse _$RejectInviteResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -258,13 +258,13 @@ RejectInviteResponse _$RejectInviteResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..message = json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?);
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
EmptyResponse _$EmptyResponseFromJson(Map<String, dynamic> json) {
|
||||
@@ -276,9 +276,9 @@ ChannelStateResponse _$ChannelStateResponseFromJson(Map<String, dynamic> json) {
|
||||
..duration = json['duration'] as String?
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?)
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>)
|
||||
..messages = (json['messages'] as List<dynamic>?)
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..members = (json['members'] as List<dynamic>?)
|
||||
?.map((e) => Member.fromJson(e as Map<String, dynamic>))
|
||||
|
||||
@@ -16,7 +16,7 @@ ChannelModel _$ChannelModelFromJson(Map<String, dynamic> json) {
|
||||
: ChannelConfig.fromJson(json['config'] as Map<String, dynamic>),
|
||||
createdBy: json['created_by'] == null
|
||||
? null
|
||||
: User.fromJson(json['created_by'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['created_by'] as Map<String, dynamic>),
|
||||
frozen: json['frozen'] as bool? ?? false,
|
||||
lastMessageAt: json['last_message_at'] == null
|
||||
? null
|
||||
|
||||
@@ -10,9 +10,9 @@ ChannelState _$ChannelStateFromJson(Map<String, dynamic> json) {
|
||||
return ChannelState(
|
||||
channel: json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?),
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
messages: (json['messages'] as List<dynamic>?)
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
members: (json['members'] as List<dynamic>?)
|
||||
@@ -20,12 +20,12 @@ ChannelState _$ChannelStateFromJson(Map<String, dynamic> json) {
|
||||
.toList() ??
|
||||
[],
|
||||
pinnedMessages: (json['pinned_messages'] as List<dynamic>?)
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Message.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
watcherCount: json['watcher_count'] as int?,
|
||||
watchers: (json['watchers'] as List<dynamic>?)
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
read: (json['read'] as List<dynamic>?)
|
||||
|
||||
@@ -16,22 +16,22 @@ Event _$EventFromJson(Map<String, dynamic> json) {
|
||||
: DateTime.parse(json['created_at'] as String),
|
||||
me: json['me'] == null
|
||||
? null
|
||||
: OwnUser.fromJson(json['me'] as Map<String, dynamic>?),
|
||||
: OwnUser.fromJson(json['me'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
message: json['message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>?),
|
||||
: Message.fromJson(json['message'] as Map<String, dynamic>),
|
||||
totalUnreadCount: json['total_unread_count'] as int?,
|
||||
unreadChannels: json['unread_channels'] as int?,
|
||||
reaction: json['reaction'] == null
|
||||
? null
|
||||
: Reaction.fromJson(json['reaction'] as Map<String, dynamic>?),
|
||||
: Reaction.fromJson(json['reaction'] as Map<String, dynamic>),
|
||||
online: json['online'] as bool?,
|
||||
channel: json['channel'] == null
|
||||
? null
|
||||
: EventChannel.fromJson(json['channel'] as Map<String, dynamic>?),
|
||||
: EventChannel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
member: json['member'] == null
|
||||
? null
|
||||
: Member.fromJson(json['member'] as Map<String, dynamic>),
|
||||
@@ -84,7 +84,7 @@ EventChannel _$EventChannelFromJson(Map<String, dynamic> json) {
|
||||
config: ChannelConfig.fromJson(json['config'] as Map<String, dynamic>),
|
||||
createdBy: json['created_by'] == null
|
||||
? null
|
||||
: User.fromJson(json['created_by'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['created_by'] as Map<String, dynamic>),
|
||||
frozen: json['frozen'] as bool? ?? false,
|
||||
lastMessageAt: json['last_message_at'] == null
|
||||
? null
|
||||
|
||||
@@ -10,7 +10,7 @@ Member _$MemberFromJson(Map<String, dynamic> json) {
|
||||
return Member(
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
inviteAcceptedAt: json['invite_accepted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['invite_accepted_at'] as String),
|
||||
|
||||
@@ -15,7 +15,7 @@ Message _$MessageFromJson(Map<String, dynamic> json) {
|
||||
?.map((e) => Attachment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
mentionedUsers: (json['mentioned_users'] as List<dynamic>?)
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
silent: json['silent'] as bool?,
|
||||
shadowed: json['shadowed'] as bool?,
|
||||
@@ -26,19 +26,19 @@ Message _$MessageFromJson(Map<String, dynamic> json) {
|
||||
(k, e) => MapEntry(k, e as int),
|
||||
),
|
||||
latestReactions: (json['latest_reactions'] as List<dynamic>?)
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
ownReactions: (json['own_reactions'] as List<dynamic>?)
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
parentId: json['parent_id'] as String?,
|
||||
quotedMessage: json['quoted_message'] == null
|
||||
? null
|
||||
: Message.fromJson(json['quoted_message'] as Map<String, dynamic>?),
|
||||
: Message.fromJson(json['quoted_message'] as Map<String, dynamic>),
|
||||
quotedMessageId: json['quoted_message_id'] as String?,
|
||||
replyCount: json['reply_count'] as int?,
|
||||
threadParticipants: (json['thread_participants'] as List<dynamic>?)
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
|
||||
?.map((e) => User.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
showInChannel: json['show_in_channel'] as bool?,
|
||||
command: json['command'] as String?,
|
||||
@@ -50,7 +50,7 @@ Message _$MessageFromJson(Map<String, dynamic> json) {
|
||||
: DateTime.parse(json['updated_at'] as String),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
pinned: json['pinned'] as bool?,
|
||||
pinnedAt: json['pinned_at'] == null
|
||||
? null
|
||||
@@ -60,7 +60,7 @@ Message _$MessageFromJson(Map<String, dynamic> json) {
|
||||
: DateTime.parse(json['pin_expires'] as String),
|
||||
pinnedBy: json['pinned_by'] == null
|
||||
? null
|
||||
: User.fromJson(json['pinned_by'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['pinned_by'] as Map<String, dynamic>),
|
||||
extraData: json['extra_data'] as Map<String, dynamic>?,
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
|
||||
@@ -10,10 +10,10 @@ Mute _$MuteFromJson(Map<String, dynamic> json) {
|
||||
return Mute(
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
channel: json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>?),
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
createdAt: json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String),
|
||||
|
||||
@@ -10,13 +10,14 @@ class Reaction {
|
||||
/// Constructor used for json serialization
|
||||
Reaction({
|
||||
this.messageId,
|
||||
required this.createdAt,
|
||||
required this.type,
|
||||
DateTime? createdAt,
|
||||
this.type = '',
|
||||
required this.user,
|
||||
String? userId,
|
||||
required this.score,
|
||||
this.score = 0,
|
||||
this.extraData,
|
||||
}) : userId = userId ?? user.id;
|
||||
}) : userId = userId ?? user.id,
|
||||
createdAt = createdAt ?? DateTime.now();
|
||||
|
||||
/// Create a new instance from a json
|
||||
factory Reaction.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -40,6 +41,7 @@ class Reaction {
|
||||
final User user;
|
||||
|
||||
/// The score of the reaction (ie. number of reactions sent)
|
||||
@JsonKey(defaultValue: 0)
|
||||
final int score;
|
||||
|
||||
/// The userId that sent the reaction
|
||||
|
||||
@@ -9,11 +9,13 @@ part of 'reaction.dart';
|
||||
Reaction _$ReactionFromJson(Map<String, dynamic> json) {
|
||||
return Reaction(
|
||||
messageId: json['message_id'] as String?,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
createdAt: json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String),
|
||||
type: json['type'] as String,
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
userId: json['user_id'] as String?,
|
||||
score: json['score'] as int,
|
||||
score: json['score'] as int? ?? 0,
|
||||
extraData: json['extra_data'] as Map<String, dynamic>?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ part of 'read.dart';
|
||||
Read _$ReadFromJson(Map<String, dynamic> json) {
|
||||
return Read(
|
||||
lastRead: DateTime.parse(json['last_read'] as String),
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>?),
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
unreadMessages: json['unread_messages'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('should return null', () {
|
||||
final result = Serialization.moveToExtraDataFromRoot(null, [
|
||||
final result = Serialization.moveToExtraDataFromRoot({}, [
|
||||
'prop1',
|
||||
'prop2',
|
||||
]);
|
||||
|
||||
expect(result, null);
|
||||
expect(result, {'extra_data': {}});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user