Show counts for replies, likes, and announces for selected notice.
authorPhil Hagelberg <phil@hagelb.org>
Wed, 30 Oct 2019 05:05:18 +0000 (22:05 -0700)
committerPhil Hagelberg <phil@hagelb.org>
Sun, 10 Nov 2019 02:07:50 +0000 (18:07 -0800)
Using text instead of an icon, for now.

lib/pleroma/web/static_fe/static_fe_controller.ex
lib/pleroma/web/templates/layout/static_fe.html.eex
lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex

index fe2fb09c4d878405f14ef43c844c09699854e41d..d2e72b47642da6e50f75639b76b0c6391cba3c63 100644 (file)
@@ -24,6 +24,16 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
 
   defp get_title(_), do: nil
 
+  def get_counts(%Activity{} = activity) do
+    %Object{data: data} = Object.normalize(activity)
+
+    %{
+      likes: data["like_count"] || 0,
+      replies: data["repliesCount"] || 0,
+      announces: data["announcement_count"] || 0
+    }
+  end
+
   def represent(%Activity{} = activity, %User{} = user, selected) do
     %{
       user: user,
@@ -33,7 +43,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
       link: Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity.id),
       published: activity.object.data["published"],
       sensitive: activity.object.data["sensitive"],
-      selected: selected
+      selected: selected,
+      counts: get_counts(activity)
     }
   end
 
@@ -50,7 +61,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
 
     represented =
       for a <- Enum.reverse(activities) do
-        represent(activity, a.object.id == activity.object.id)
+        represent(a, a.object.id == activity.object.id)
       end
 
     render(conn, "conversation.html", %{activities: represented, instance_name: instance_name})
index 9d7ee366a3f8b5012db8962a6afc6034c1723147..e42047de904e512d9658825ca27f9967990bbdb4 100644 (file)
@@ -24,6 +24,7 @@
 
       .activity {
         padding: 1em;
+        padding-bottom: 2em;
         margin-bottom: 1em;
       }
 
         background-color: #1b2735;
       }
 
+      .counts dt, .counts dd {
+        float: left;
+        margin-left: 1em;
+      }
+
       a {
         color: white;
       }
index 9841fcf8469309436af7deb20151a102eb096ec8..2a46dadb4fe6ca5b247a9669b0541169278b3aa9 100644 (file)
       <% end %>
     <% end %>
   </div>
+  <%= if @selected do %>
+    <dl class="counts">
+      <dt><%= Gettext.gettext("replies") %></dt><dd><%= @counts.replies %></dd>
+      <dt><%= Gettext.gettext("announces") %></dt><dd><%= @counts.announces %></dd>
+      <dt><%= Gettext.gettext("likes") %></dt><dd><%= @counts.likes %></dd>
+    </dl>
+  <% end %>
 </div>