Class: Collavre::CommentReaction
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Collavre::CommentReaction
- Defined in:
- app/models/collavre/comment_reaction.rb
Class Method Summary collapse
Class Method Details
.broadcast_reaction_update(comment) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/collavre/comment_reaction.rb', line 11 def self.broadcast_reaction_update(comment) creative = comment.creative reactions = comment.comment_reactions.reload.to_a payload = reactions.group_by(&:emoji).map do |emoji, grouped| { emoji: emoji, count: grouped.size, user_ids: grouped.map(&:user_id) } end Turbo::StreamsChannel.broadcast_action_to( [ creative, :comments ], action: "update_reactions", target: "comment_#{comment.id}", attributes: { data: payload.to_json } ) end |