shouldUpdateReaction method

bool shouldUpdateReaction(
  1. List<Reaction> reactions,
  2. String identity,
  3. String newEmoji
)

Implementation

bool shouldUpdateReaction(
    List<Reaction> reactions,
    String identity,
    String newEmoji,
    ) {
  if (identity == "" || newEmoji == "") return true;
  final existing = reactions.firstWhere(
        (r) => r.reactor == identity,
    orElse: () => Reaction(),
  );

  if (existing.reactor == null) {
    // User hasn't reacted yet → adding
    return true;
  }

  if (existing.emoji == newEmoji) {
    // Same emoji → removing
    return false;
  }

  // Different emoji → updating
  return true;
}