Merge pull request #1718 from GetStream/fix/reply-update

This commit is contained in:
Sahil Kumar
2023-08-24 13:53:16 +05:30
committed by GitHub
3 changed files with 39 additions and 14 deletions
+7
View File
@@ -1,3 +1,10 @@
## Upcoming
🐞 Fixed
- [[#1716]](https://github.com/GetStream/stream-chat-flutter/issues/1716) Fixed client not able to
update message with `type: reply`.
## 6.8.0
🐞 Fixed
@@ -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;
}