chore(llc): json annotation changes
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -135,7 +135,6 @@ class Attachment extends Equatable {
|
|||||||
late final UploadState uploadState;
|
late final UploadState uploadState;
|
||||||
|
|
||||||
/// Map of custom channel extraData
|
/// Map of custom channel extraData
|
||||||
@JsonKey(includeIfNull: false)
|
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
|
|
||||||
/// The attachment ID.
|
/// The attachment ID.
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ class ChannelModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Map of custom channel extraData
|
/// Map of custom channel extraData
|
||||||
@JsonKey(includeIfNull: false)
|
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
|
|
||||||
/// The team the channel belongs to
|
/// The team the channel belongs to
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class Message extends Equatable {
|
|||||||
final String? parentId;
|
final String? parentId;
|
||||||
|
|
||||||
/// A quoted reply message.
|
/// A quoted reply message.
|
||||||
@JsonKey(toJson: Serializer.readOnly)
|
@JsonKey(includeToJson: false)
|
||||||
final Message? quotedMessage;
|
final Message? quotedMessage;
|
||||||
|
|
||||||
final String? _quotedMessageId;
|
final String? _quotedMessageId;
|
||||||
@@ -185,7 +185,7 @@ class Message extends Equatable {
|
|||||||
final bool pinned;
|
final bool pinned;
|
||||||
|
|
||||||
/// Reserved field indicating when the message was pinned.
|
/// Reserved field indicating when the message was pinned.
|
||||||
@JsonKey(toJson: Serializer.readOnly)
|
@JsonKey(includeToJson: false)
|
||||||
final DateTime? pinnedAt;
|
final DateTime? pinnedAt;
|
||||||
|
|
||||||
/// Reserved field indicating when the message will expire.
|
/// Reserved field indicating when the message will expire.
|
||||||
@@ -194,11 +194,10 @@ class Message extends Equatable {
|
|||||||
final DateTime? pinExpires;
|
final DateTime? pinExpires;
|
||||||
|
|
||||||
/// Reserved field indicating who pinned the message.
|
/// Reserved field indicating who pinned the message.
|
||||||
@JsonKey(toJson: Serializer.readOnly)
|
@JsonKey(includeToJson: false)
|
||||||
final User? pinnedBy;
|
final User? pinnedBy;
|
||||||
|
|
||||||
/// Message custom extraData.
|
/// Message custom extraData.
|
||||||
@JsonKey(includeIfNull: false)
|
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
|
|
||||||
/// True if the message is a system info.
|
/// True if the message is a system info.
|
||||||
@@ -211,7 +210,7 @@ class Message extends Equatable {
|
|||||||
bool get isEphemeral => type == 'ephemeral';
|
bool get isEphemeral => type == 'ephemeral';
|
||||||
|
|
||||||
/// A Map of translations.
|
/// A Map of translations.
|
||||||
@JsonKey(includeIfNull: false)
|
@JsonKey(includeToJson: false)
|
||||||
final Map<String, String>? i18n;
|
final Map<String, String>? i18n;
|
||||||
|
|
||||||
/// Known top level fields.
|
/// Known top level fields.
|
||||||
|
|||||||
@@ -71,30 +71,16 @@ Message _$MessageFromJson(Map<String, dynamic> json) => Message(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$MessageToJson(Message instance) {
|
Map<String, dynamic> _$MessageToJson(Message instance) => <String, dynamic>{
|
||||||
final val = <String, dynamic>{
|
'id': instance.id,
|
||||||
'id': instance.id,
|
'text': instance.text,
|
||||||
'text': instance.text,
|
'attachments': instance.attachments.map((e) => e.toJson()).toList(),
|
||||||
'attachments': instance.attachments.map((e) => e.toJson()).toList(),
|
'mentioned_users': User.toIds(instance.mentionedUsers),
|
||||||
'mentioned_users': User.toIds(instance.mentionedUsers),
|
'parent_id': instance.parentId,
|
||||||
'parent_id': instance.parentId,
|
'quoted_message_id': instance.quotedMessageId,
|
||||||
'quoted_message': readonly(instance.quotedMessage),
|
'show_in_channel': instance.showInChannel,
|
||||||
'quoted_message_id': instance.quotedMessageId,
|
'silent': instance.silent,
|
||||||
'show_in_channel': instance.showInChannel,
|
'pinned': instance.pinned,
|
||||||
'silent': instance.silent,
|
'pin_expires': instance.pinExpires?.toIso8601String(),
|
||||||
'pinned': instance.pinned,
|
'extra_data': instance.extraData,
|
||||||
'pinned_at': readonly(instance.pinnedAt),
|
};
|
||||||
'pin_expires': instance.pinExpires?.toIso8601String(),
|
|
||||||
'pinned_by': readonly(instance.pinnedBy),
|
|
||||||
'extra_data': instance.extraData,
|
|
||||||
};
|
|
||||||
|
|
||||||
void writeNotNull(String key, dynamic value) {
|
|
||||||
if (value != null) {
|
|
||||||
val[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeNotNull('i18n', instance.i18n);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class Reaction {
|
|||||||
final String? userId;
|
final String? userId;
|
||||||
|
|
||||||
/// Reaction custom extraData
|
/// Reaction custom extraData
|
||||||
@JsonKey(includeIfNull: false)
|
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
|
|
||||||
/// Map of custom user extraData
|
/// Map of custom user extraData
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class User extends Equatable {
|
|||||||
final String? language;
|
final String? language;
|
||||||
|
|
||||||
/// Map of custom user extraData.
|
/// Map of custom user extraData.
|
||||||
@JsonKey(includeIfNull: false)
|
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
|
|
||||||
/// List of users to list of userIds.
|
/// List of users to list of userIds.
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
/// Used to avoid to serialize properties to json
|
|
||||||
// ignore: prefer_void_to_null
|
|
||||||
Null readonly(_) => null;
|
|
||||||
|
|
||||||
/// Helper class for serialization to and from json
|
/// Helper class for serialization to and from json
|
||||||
class Serializer {
|
class Serializer {
|
||||||
/// Used to avoid to serialize properties to json
|
|
||||||
static const Function readOnly = readonly;
|
|
||||||
|
|
||||||
/// Takes unknown json keys and puts them in the `extra_data` key
|
/// Takes unknown json keys and puts them in the `extra_data` key
|
||||||
static Map<String, dynamic> moveToExtraDataFromRoot(
|
static Map<String, dynamic> moveToExtraDataFromRoot(
|
||||||
Map<String, dynamic> json,
|
Map<String, dynamic> json,
|
||||||
|
|||||||
Reference in New Issue
Block a user