Update UI to display reactions

This commit is contained in:
Jamie Bliss 2023-11-10 14:54:44 -05:00
parent b3e67ffe3a
commit 54bddb0dd7
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View file

@ -471,6 +471,7 @@ class Post(StatorModel):
"likes": self.stats.get("likes", 0) if self.stats else 0, "likes": self.stats.get("likes", 0) if self.stats else 0,
"boosts": self.stats.get("boosts", 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, "replies": self.stats.get("replies", 0) if self.stats else 0,
"reactions": self.stats.get("reactions", {}) if self.stats else {},
} }
### Local creation/editing ### ### Local creation/editing ###
@ -620,7 +621,7 @@ class Post(StatorModel):
).count(), ).count(),
"replies": Post.objects.filter(in_reply_to=self.object_uri).count(), "replies": Post.objects.filter(in_reply_to=self.object_uri).count(),
"reactions": { "reactions": {
row["value"]: row["count"] row["value"] or "": row["count"]
for row in self.interactions.filter( for row in self.interactions.filter(
type=PostInteraction.Types.like, type=PostInteraction.Types.like,
state__in=PostInteractionStates.group_active(), state__in=PostInteractionStates.group_active(),

View file

@ -78,10 +78,16 @@
<i class="fa-solid fa-reply"></i> <i class="fa-solid fa-reply"></i>
<span class="like-count">{{ post.stats_with_defaults.replies|default:"0" }}</span> <span class="like-count">{{ post.stats_with_defaults.replies|default:"0" }}</span>
</a> </a>
<a title="Likes" class="no-action"> {% for reaction, count in post.stats_with_defaults.reactions.items %}
<i class="fa-solid fa-star"></i> <a title="Reaction {{reaction}}" class="no-action">
<span class="like-count">{{ post.stats_with_defaults.likes|default:"0" }}</span> {% if reaction %}
</a> <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"> <a title="Boosts" class="no-action">
<i class="fa-solid fa-retweet"></i> <i class="fa-solid fa-retweet"></i>
<span class="like-count">{{ post.stats_with_defaults.boosts|default:"0" }}</span> <span class="like-count">{{ post.stats_with_defaults.boosts|default:"0" }}</span>