Skip to content

Commit

Permalink
fix: 🐛 user reaction callback provides incorrect message object when …
Browse files Browse the repository at this point in the history
…user react on any message

- Update user reaction callback when user react on any message callback provides reacted emoji and message object that contains same reacted emoji in reaction emoji list.
  • Loading branch information
apurva010 committed May 21, 2024
1 parent 67b8021 commit 93012a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [1.3.2] (Unreleased)

* **Fix**: [165](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/165) Fix issue
of user reaction callback provides incorrect message object when user react on any message
with double or from reaction sheet.
* **Fix**: [160](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/160) Added
configuration for emoji picker sheet.
* **Fix**: [130](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/130) Added
Expand Down
4 changes: 2 additions & 2 deletions lib/src/models/reaction_popup_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
import 'package:flutter/material.dart';

import 'models.dart';
import '../values/typedefs.dart';

class ReactionPopupConfiguration {
/// Used for background color in reaction pop-up.
Expand Down Expand Up @@ -52,7 +52,7 @@ class ReactionPopupConfiguration {
final GlassMorphismConfiguration? glassMorphismConfig;

/// Provides callback when user react on message.
final void Function(Message message, String emoji)? userReactionCallback;
final ReactionCallback? userReactionCallback;

const ReactionPopupConfiguration({
this.userReactionCallback,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/values/typedefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ typedef MoreTapCallBack = void Function(
Message message,
bool sendByCurrentUser,
);
typedef ReactionCallback = void Function(
Message message,
String emoji,
);
8 changes: 4 additions & 4 deletions lib/src/widgets/reaction_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ class ReactionPopupState extends State<ReactionPopup>
onEmojiTap: (emoji) {
widget.onTap();
if (currentUser != null && _message != null) {
reactionPopupConfig?.userReactionCallback?.call(
_message!,
emoji,
);
chatController?.setReaction(
emoji: emoji,
messageId: _message!.id,
userId: currentUser!.id,
);
reactionPopupConfig?.userReactionCallback?.call(
_message!,
emoji,
);
}
},
emojiConfiguration: reactionPopupConfig?.emojiConfig,
Expand Down

0 comments on commit 93012a5

Please sign in to comment.