feat: Add edit message support. (closes #336)#438
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class “edit message” support to ChatView, wiring an edit action from the long-press popup into the input area, and exposing callbacks/localization needed for consumers to update their message source-of-truth.
Changes:
- Introduces edit-mode state in the input (
SendMessageWidget) with a newEditMessageViewindicator andEditMessageCallback. - Adds an “Edit” option to the reply popup (own messages only) and threads
assignEditMessagethroughChatListWidget -> ChatView. - Adds locale strings (
edit/edited/editing), an “Edited” label for updated messages, and documentation/changelog updates.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/widgets/send_message_widget.dart | Adds edit-mode state, assigns an editing message, and routes Send to onEditTap when editing. |
| lib/src/widgets/reply_popup_widget.dart | Adds an optional “Edit” button to the long-press popup (own messages only). |
| lib/src/widgets/edit_message_view.dart | New widget to display an editing indicator above the input area. |
| lib/src/widgets/chat_view.dart | Exposes onEditTap, wires assignEditMessage, and adds getEditingMessage() helper. |
| lib/src/widgets/chat_list_widget.dart | Wires the popup Edit action to enter edit mode and call configuration callback. |
| lib/src/widgets/chat_bubble_widget.dart | Displays an “Edited” label when updateAt is non-null. |
| lib/src/values/typedefs.dart | Adds EditMessageCallback typedef. |
| lib/src/utils/chat_view_locale.dart | Adds edit/edited/editing strings (backward-compatible defaults). |
| lib/src/models/config_models/reply_popup_configuration.dart | Adds onEditTap to reply popup configuration. |
| lib/src/models/config_models/feature_active_config.dart | Adds enableEditMessage flag (default true). |
| lib/chatview.dart | Exports EditMessageView. |
| doc/documentation.md | Documents the new Edit Message feature and integration steps. |
| CHANGELOG.md | Adds unreleased changelog entry for edit-message support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _textEditingController.clear(); | ||
| if (messageText.isEmpty) return; | ||
|
|
||
| // If in edit mode, delegate to onEditTap instead of onSendTap. | ||
| if (isEditMode) { | ||
| widget.onEditTap?.call(_editingMessage!, messageText); | ||
| _closeEditMode(); | ||
| return; | ||
| } | ||
|
|
| if (_editMessageViewKey.currentState == null) { | ||
| setState(() {}); | ||
| } else { | ||
| _editMessageViewKey.currentState!.editMessage.value = message; | ||
| } | ||
| } |
| onEditTap: sentByCurrentUser && | ||
| (featureActiveConfig?.enableEditMessage ?? true) | ||
| ? () { | ||
| widget.assignEditMessage?.call(message); | ||
| if (featureActiveConfig?.enableReactionPopup ?? false) { | ||
| chatViewIW?.showPopUp.value = false; | ||
| } | ||
| ScaffoldMessenger.of(context).hideCurrentSnackBar(); | ||
| replyPopup?.onEditTap?.call(message); | ||
| } |
There was a problem hiding this comment.
take this as separate function for code readability
| /// Displays an "Editing" header with the original message preview and a | ||
| /// close button to cancel the edit. |
a427094 to
acb9181
Compare
16e7b32 to
9eedc33
Compare
| /// [newText] is the updated text content. | ||
| typedef EditMessageCallback = void Function( | ||
| Message message, | ||
| String newText, |
There was a problem hiding this comment.
change the parameter name to updatedMessage or editedMessage.
| ReplyMessage _replyMessage = const ReplyMessage(); | ||
|
|
||
| /// The message currently being edited, or `null` if not in edit mode. | ||
| Message? _editingMessage; |
There was a problem hiding this comment.
please check for naming convention, editingMessage seems to be a method name.
| /// message text in-place. | ||
| /// | ||
| /// Defaults to `true`. | ||
| final bool enableEditMessage; |
There was a problem hiding this comment.
can we rename to enableMessageEditing?
There was a problem hiding this comment.
readme needs to be update with this changes too
9eedc33 to
cfb66dc
Compare
- Add enableEditMessage flag to FeatureActiveConfig (default: true) - Add onEditTap callback to ChatView and ReplyPopupConfiguration - Add EditMessageCallback typedef - Create EditMessageView widget showing 'Editing' indicator above textfield - Extend SendMessageWidget with assignEditMessage() and edit mode logic - Add Edit button to ReplyPopupWidget (own messages only) - Wire assignEditMessage through ChatListWidget -> ChatView - Show 'Edited' label on messages where updateAt is non-null - Add edit/edited/editing strings to ChatViewLocale (backward-compatible) - Expose ChatView.getEditingMessage() static helper - Add doc/documentation.md section for Edit Message feature
cfb66dc to
372f7aa
Compare
| message: newText, | ||
| createdAt: originalMessage.createdAt, | ||
| sentBy: originalMessage.sentBy, | ||
| updateAt: DateTime.now(), // marks the message as edited |
There was a problem hiding this comment.
updatedAt
| // Set `updateAt` on the message to trigger the "Edited" label in the UI. | ||
| final updatedMessage = Message( | ||
| id: originalMessage.id, | ||
| message: newText, |
There was a problem hiding this comment.
newMessage
| ```dart | ||
| ChatView( | ||
| // ... | ||
| onEditTap: (Message originalMessage, String newText) { |
There was a problem hiding this comment.
onEditTap seems to be the callback when we click on edit button.
There was a problem hiding this comment.
onEditTap is a callback when we click on the edit button. so naming convention looks proper to me.
| ```dart | ||
| ChatView( | ||
| // ... | ||
| onEditTap: (Message originalMessage, String newText) { |
There was a problem hiding this comment.
instead of string we should pass message object only
| this.enableOtherUserName = true, | ||
| this.enableScrollToBottomButton = false, | ||
| this.enableTextSelection = false, | ||
| this.enableMessageEditing = true, |
There was a problem hiding this comment.
It should default to false.
569e1ea to
29252dd
Compare
…tegration examples
29252dd to
5fcc22f
Compare
Description
Visual Representation
Screen_recording_20260512_135107.mp4
Checklist
fix:,feat:,docs:etc).docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #336