From f51104accc95aec8bc2a19a89d7d60ad36f67f8d Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 28 Aug 2024 16:12:42 -0500 Subject: [PATCH] Squash boosts into one-liners between comments --- app/assets/stylesheets/splats.css | 2 +- app/views/comments/_comment.html.erb | 30 +++++++++++----------------- app/views/splats/show.html.erb | 20 +++++++++++++++++-- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/splats.css b/app/assets/stylesheets/splats.css index 2fe1d9172..5f3952032 100644 --- a/app/assets/stylesheets/splats.css +++ b/app/assets/stylesheets/splats.css @@ -61,7 +61,7 @@ } .splat__perma & { - --splat-size: 50vh !important; + --splat-size: 40vh !important; } } diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 7a470150b..f60a72c6e 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,20 +1,14 @@ -<% if comment.is_a?(Boost) %> -
- <%= comment.creator.name %> + 1 -
-<% else %> -
" id="<%= dom_id(comment) %>"> - <%= comment.creator.initials %> -
-
- <%= comment.creator.name %> - <%= link_to splat_path(@splat, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %> - - <% end %> -
-
- <%= simple_format comment.body %> -
+
" id="<%= dom_id(comment) %>"> + <%= comment.creator.initials %> +
+
+ <%= comment.creator.name %> + <%= link_to splat_path(@splat, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %> + + <% end %> +
+
+ <%= simple_format comment.body %>
-<% end %> +
diff --git a/app/views/splats/show.html.erb b/app/views/splats/show.html.erb index c10748816..4acd04aeb 100644 --- a/app/views/splats/show.html.erb +++ b/app/views/splats/show.html.erb @@ -24,7 +24,23 @@ <%= render @splat %>
-
- <%= render partial: "comments/comment", collection: (@splat.comments + @splat.boosts).sort_by { |comment| comment.updated_at } %> +
+ <% comments = (@splat.comments + @splat.boosts).sort_by(&:updated_at) %> + <% boosts = [] %> + + <% comments.each_with_index do |comment, index| %> + <% if comment.is_a?(Boost) %> + <% boosts << comment %> + <% if comments[index + 1].nil? || !comments[index + 1].is_a?(Boost) %> + <% user_boosts = boosts.group_by(&:creator).transform_values(&:count) %> +
+ <%= user_boosts.map { |user, count| "#{user.name} +#{count}" }.to_sentence %> +
+ <% boosts.clear %> + <% end %> + <% else %> + <%= render partial: "comments/comment", object: comment %> + <% end %> + <% end %> <%= render "comments/new" %>