From 1478933cf17e8f68c2f9b637cf614543491d1a59 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 4 Mar 2025 21:59:18 +0800 Subject: [PATCH] :bug: Fix editing message mock issue --- lib/controllers/chat_message_controller.dart | 37 +++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/controllers/chat_message_controller.dart b/lib/controllers/chat_message_controller.dart index e7a5220..7d3931d 100644 --- a/lib/controllers/chat_message_controller.dart +++ b/lib/controllers/chat_message_controller.dart @@ -287,23 +287,26 @@ class ChatMessageController extends ChangeNotifier { }; // Mock the message locally - final createdAt = DateTime.now(); - final message = SnChatMessage( - id: 0, - createdAt: createdAt, - updatedAt: createdAt, - deletedAt: null, - uuid: nonce, - body: body, - type: type, - channel: channel!, - channelId: channel!.id, - sender: profile!, - senderId: profile!.id, - quoteEventId: quoteId, - relatedEventId: relatedId, - ); - _addUnconfirmedMessage(message); + // Do not mock the editing message + if (editingMessage == null) { + final createdAt = DateTime.now(); + final message = SnChatMessage( + id: 0, + createdAt: createdAt, + updatedAt: createdAt, + deletedAt: null, + uuid: nonce, + body: body, + type: type, + channel: channel!, + channelId: channel!.id, + sender: profile!, + senderId: profile!.id, + quoteEventId: quoteId, + relatedEventId: relatedId, + ); + _addUnconfirmedMessage(message); + } // Send to server try {