fix(llc): fix not able to update message with type: reply.
Signed-off-by: Sahil Kumar <xdsahil@gmail.com>
This commit is contained in:
@@ -168,8 +168,16 @@ class Message extends Equatable {
|
||||
late final MessageState state;
|
||||
|
||||
/// The message type.
|
||||
@JsonKey(includeIfNull: false, toJson: _typeToJson)
|
||||
final String type;
|
||||
|
||||
// We need to skip passing type if it's not regular or system as the API
|
||||
// does not expect it.
|
||||
static String? _typeToJson(String type) {
|
||||
if (['regular', 'system'].contains(type)) return type;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// The list of attachments, either provided by the user or generated from a
|
||||
/// command or as a result of URL scraping.
|
||||
@JsonKey(includeIfNull: false)
|
||||
|
||||
@@ -71,17 +71,27 @@ Message _$MessageFromJson(Map<String, dynamic> json) => Message(
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MessageToJson(Message instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'text': instance.text,
|
||||
'type': instance.type,
|
||||
'attachments': instance.attachments.map((e) => e.toJson()).toList(),
|
||||
'mentioned_users': User.toIds(instance.mentionedUsers),
|
||||
'parent_id': instance.parentId,
|
||||
'quoted_message_id': instance.quotedMessageId,
|
||||
'show_in_channel': instance.showInChannel,
|
||||
'silent': instance.silent,
|
||||
'pinned': instance.pinned,
|
||||
'pin_expires': instance.pinExpires?.toIso8601String(),
|
||||
'extra_data': instance.extraData,
|
||||
};
|
||||
Map<String, dynamic> _$MessageToJson(Message instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'text': instance.text,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('type', Message._typeToJson(instance.type));
|
||||
val['attachments'] = instance.attachments.map((e) => e.toJson()).toList();
|
||||
val['mentioned_users'] = User.toIds(instance.mentionedUsers);
|
||||
val['parent_id'] = instance.parentId;
|
||||
val['quoted_message_id'] = instance.quotedMessageId;
|
||||
val['show_in_channel'] = instance.showInChannel;
|
||||
val['silent'] = instance.silent;
|
||||
val['pinned'] = instance.pinned;
|
||||
val['pin_expires'] = instance.pinExpires?.toIso8601String();
|
||||
val['extra_data'] = instance.extraData;
|
||||
return val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user