fix models

This commit is contained in:
Salvatore Giordano
2021-04-13 15:48:05 +02:00
parent fe07b8dbb0
commit 97c35371af
29 changed files with 193 additions and 308 deletions
@@ -6,49 +6,39 @@ part of 'message.dart';
// JsonSerializableGenerator
// **************************************************************************
Message _$MessageFromJson(Map json) {
Message _$MessageFromJson(Map<String, dynamic> json) {
return Message(
id: json['id'] as String?,
text: json['text'] as String,
type: json['type'] as String,
attachments: (json['attachments'] as List<dynamic>?)
?.map((e) => Attachment.fromJson(Map<String, dynamic>.from(e as Map)))
?.map((e) => Attachment.fromJson(e as Map<String, dynamic>))
.toList(),
mentionedUsers: (json['mentioned_users'] as List<dynamic>?)
?.map((e) => User.fromJson((e as Map?)?.map(
(k, e) => MapEntry(k as String, e),
)))
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
.toList(),
silent: json['silent'] as bool?,
shadowed: json['shadowed'] as bool?,
reactionCounts: (json['reaction_counts'] as Map?)?.map(
(k, e) => MapEntry(k as String, e as int),
reactionCounts: (json['reaction_counts'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as int),
),
reactionScores: (json['reaction_scores'] as Map?)?.map(
(k, e) => MapEntry(k as String, e as int),
reactionScores: (json['reaction_scores'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as int),
),
latestReactions: (json['latest_reactions'] as List<dynamic>?)
?.map((e) => Reaction.fromJson((e as Map?)?.map(
(k, e) => MapEntry(k as String, e),
)))
?.map((e) => Reaction.fromJson(e as Map<String, dynamic>?))
.toList(),
ownReactions: (json['own_reactions'] as List<dynamic>?)
?.map((e) => Reaction.fromJson((e as Map?)?.map(
(k, e) => MapEntry(k as String, e),
)))
?.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?)?.map(
(k, e) => MapEntry(k as String, e),
)),
: 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?)?.map(
(k, e) => MapEntry(k as String, e),
)))
?.map((e) => User.fromJson(e as Map<String, dynamic>?))
.toList(),
showInChannel: json['show_in_channel'] as bool?,
command: json['command'] as String?,
@@ -56,9 +46,7 @@ Message _$MessageFromJson(Map json) {
updatedAt: DateTime.parse(json['updated_at'] as String),
user: json['user'] == null
? null
: User.fromJson((json['user'] as Map?)?.map(
(k, e) => MapEntry(k as String, e),
)),
: User.fromJson(json['user'] as Map<String, dynamic>?),
pinned: json['pinned'] as bool?,
pinnedAt: json['pinned_at'] == null
? null
@@ -68,12 +56,8 @@ Message _$MessageFromJson(Map json) {
: DateTime.parse(json['pin_expires'] as String),
pinnedBy: json['pinned_by'] == null
? null
: User.fromJson((json['pinned_by'] as Map?)?.map(
(k, e) => MapEntry(k as String, e),
)),
extraData: (json['extra_data'] as Map?)?.map(
(k, e) => MapEntry(k as String, e),
),
: User.fromJson(json['pinned_by'] as Map<String, dynamic>?),
extraData: json['extra_data'] as Map<String, dynamic>?,
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
@@ -123,10 +107,10 @@ Map<String, dynamic> _$MessageToJson(Message instance) {
return val;
}
TranslatedMessage _$TranslatedMessageFromJson(Map json) {
TranslatedMessage _$TranslatedMessageFromJson(Map<String, dynamic> json) {
return TranslatedMessage(
(json['i18n'] as Map?)?.map(
(k, e) => MapEntry(k as String, e as String),
(json['i18n'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
),
);
}