Skip to content

Commit

Permalink
Update UI to display reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Bliss committed Nov 10, 2023
1 parent 0228042 commit a1ef87e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion activities/models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def stats_with_defaults(self):
"likes": self.stats.get("likes", 0) if self.stats else 0,
"boosts": self.stats.get("boosts", 0) if self.stats else 0,
"replies": self.stats.get("replies", 0) if self.stats else 0,
"reactions": self.stats.get("reactions", {}) if self.stats else {},
}

### Local creation/editing ###
Expand Down Expand Up @@ -618,7 +619,7 @@ def calculate_stats(self, save=True):
).count(),
"replies": Post.objects.filter(in_reply_to=self.object_uri).count(),
"reactions": {
row["value"]: row["count"]
row["value"] or "": row["count"]
for row in self.interactions.filter(
type=PostInteraction.Types.like,
state__in=PostInteractionStates.group_active(),
Expand Down
14 changes: 10 additions & 4 deletions templates/activities/_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@
<i class="fa-solid fa-reply"></i>
<span class="like-count">{{ post.stats_with_defaults.replies|default:"0" }}</span>
</a>
<a title="Likes" class="no-action">
<i class="fa-solid fa-star"></i>
<span class="like-count">{{ post.stats_with_defaults.likes|default:"0" }}</span>
</a>
{% for reaction, count in post.stats_with_defaults.reactions.items %}
<a title="Reaction {{reaction}}" class="no-action">
{% if reaction %}
<span>{{reaction}}</span>
{% else %}
<i class="fa-solid fa-star"></i>
{% endif %}
<span class="like-count">{{count}}</span>
</a>
{% endfor %}
<a title="Boosts" class="no-action">
<i class="fa-solid fa-retweet"></i>
<span class="like-count">{{ post.stats_with_defaults.boosts|default:"0" }}</span>
Expand Down

0 comments on commit a1ef87e

Please sign in to comment.