From f3c0f4b4943f06f8f20e60a5adb79aa553f891aa Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 25 Nov 2021 17:03:17 +0530 Subject: [PATCH] fixed tests --- .../lib/src/core/models/event.dart | 1 + .../lib/src/core/models/event.g.dart | 52 +++++++++++-------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/event.dart b/packages/stream_chat/lib/src/core/models/event.dart index b8ddafa7..3522c35c 100644 --- a/packages/stream_chat/lib/src/core/models/event.dart +++ b/packages/stream_chat/lib/src/core/models/event.dart @@ -93,6 +93,7 @@ class Event { final bool isLocal; /// This is true if the message has been hard deleted + @JsonKey(includeIfNull: false) final bool? hardDelete; /// Map of custom channel extraData diff --git a/packages/stream_chat/lib/src/core/models/event.g.dart b/packages/stream_chat/lib/src/core/models/event.g.dart index 3a521c9a..660e4542 100644 --- a/packages/stream_chat/lib/src/core/models/event.g.dart +++ b/packages/stream_chat/lib/src/core/models/event.g.dart @@ -42,27 +42,37 @@ Event _$EventFromJson(Map json) => Event( isLocal: json['is_local'] as bool? ?? false, ); -Map _$EventToJson(Event instance) => { - 'type': instance.type, - 'cid': instance.cid, - 'channel_id': instance.channelId, - 'channel_type': instance.channelType, - 'connection_id': instance.connectionId, - 'created_at': instance.createdAt.toIso8601String(), - 'me': instance.me?.toJson(), - 'user': instance.user?.toJson(), - 'message': instance.message?.toJson(), - 'channel': instance.channel?.toJson(), - 'member': instance.member?.toJson(), - 'reaction': instance.reaction?.toJson(), - 'total_unread_count': instance.totalUnreadCount, - 'unread_channels': instance.unreadChannels, - 'online': instance.online, - 'parent_id': instance.parentId, - 'is_local': instance.isLocal, - 'hard_delete': instance.hardDelete, - 'extra_data': instance.extraData, - }; +Map _$EventToJson(Event instance) { + final val = { + 'type': instance.type, + 'cid': instance.cid, + 'channel_id': instance.channelId, + 'channel_type': instance.channelType, + 'connection_id': instance.connectionId, + 'created_at': instance.createdAt.toIso8601String(), + 'me': instance.me?.toJson(), + 'user': instance.user?.toJson(), + 'message': instance.message?.toJson(), + 'channel': instance.channel?.toJson(), + 'member': instance.member?.toJson(), + 'reaction': instance.reaction?.toJson(), + 'total_unread_count': instance.totalUnreadCount, + 'unread_channels': instance.unreadChannels, + 'online': instance.online, + 'parent_id': instance.parentId, + 'is_local': instance.isLocal, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('hard_delete', instance.hardDelete); + val['extra_data'] = instance.extraData; + return val; +} EventChannel _$EventChannelFromJson(Map json) => EventChannel( members: (json['members'] as List?)