From 7efc5c3dddfff0b7537d1fdce1ec6936bc76e38b Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 3 Jul 2024 14:01:44 +0200 Subject: [PATCH] fix(ui): copy message (#1973) * fix copy message bug * fix copy message bug * added changelog entry --- packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ .../lib/src/message_widget/message_widget.dart | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 2105bc934..27a1a4806 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- Fixed copy message function. + ## 7.2.2 ✅ Added diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart index a8de9bb6b..30b75717a 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart @@ -816,12 +816,11 @@ class _StreamMessageWidgetState extends State title: Text(context.translations.copyMessageLabel), onClick: () { Navigator.of(context, rootNavigator: true).pop(); - final text = widget.message.text; - String? messageToCopy; + var messageToCopy = widget.message.text; for (final user in widget.message.mentionedUsers.toSet()) { final userId = user.id; final userName = user.name; - messageToCopy = text?.replaceAll( + messageToCopy = messageToCopy?.replaceAll( RegExp('@($userId|$userName)'), '@$userName', ) ?? @@ -1040,12 +1039,11 @@ class _StreamMessageWidgetState extends State : DisplayWidget.show, ), onCopyTap: (message) { - final text = message.text; - String? messageToCopy; + var messageToCopy = message.text; for (final user in widget.message.mentionedUsers.toSet()) { final userId = user.id; final userName = user.name; - messageToCopy = text?.replaceAll( + messageToCopy = messageToCopy?.replaceAll( RegExp('@($userId|$userName)'), '@$userName', ) ??