🐛 Fix editing message did not load the attachment

This commit is contained in:
LittleSheep 2025-01-08 17:48:46 +08:00
parent 4edfa7fd50
commit fb2a55a909

View File

@ -48,6 +48,8 @@ class ChatMessageInputState extends State<ChatMessageInput> {
void setEdit(SnChatMessage? value) { void setEdit(SnChatMessage? value) {
_contentController.text = value?.body['text'] ?? ''; _contentController.text = value?.body['text'] ?? '';
_attachments.clear();
_attachments.addAll(value?.preload?.attachments?.map((e) => PostWriteMedia(e)) ?? []);
setState(() => _editingMessage = value); setState(() => _editingMessage = value);
} }
@ -199,6 +201,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
InkWell( InkWell(
child: Text('cancel'.tr()), child: Text('cancel'.tr()),
onTap: () { onTap: () {
_attachments.clear();
setState(() => _replyingMessage = null); setState(() => _replyingMessage = null);
}, },
), ),
@ -238,6 +241,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
InkWell( InkWell(
child: Text('cancel'.tr()), child: Text('cancel'.tr()),
onTap: () { onTap: () {
_attachments.clear();
_contentController.clear(); _contentController.clear();
setState(() => _editingMessage = null); setState(() => _editingMessage = null);
}, },