add follow types
This commit is contained in:
parent
f7d7170759
commit
8520de92c8
4 changed files with 24 additions and 7 deletions
|
@ -36,7 +36,7 @@
|
|||
{% if forloop.last %}
|
||||
<div class="htmx-indicator"
|
||||
style="margin-left: 60px"
|
||||
hx-get="{% url 'social:events' %}?last={{ event.created|date:'Y-m-d H:i:s.uO'|urlencode }}"
|
||||
hx-get="{% url 'social:events' %}?type={{ request.GET.type }}&last={{ event.created|date:'Y-m-d H:i:s.uO'|urlencode }}"
|
||||
hx-trigger="revealed"
|
||||
hx-swap="outerHTML">
|
||||
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
|
||||
|
|
|
@ -22,9 +22,19 @@
|
|||
{% include "_header.html" with current="timeline" %}
|
||||
<main>
|
||||
<div class="grid__main">
|
||||
<h5>{% trans 'Notification' %}</h5>
|
||||
<h5>
|
||||
{% trans 'Notification' %}
|
||||
<small>
|
||||
<a class="{% if not request.GET.type %}secondary{% endif %}"
|
||||
href="{% url 'social:notification' %}">all</a> |
|
||||
<a class="{% if request.GET.type == 'mention' %}secondary{% endif %}"
|
||||
href="{% url 'social:notification' %}?type=mention">mention</a> |
|
||||
<a class="{% if request.GET.type == 'follow' %}secondary{% endif %}"
|
||||
href="{% url 'social:notification' %}?type=follow">follow</a>
|
||||
</small>
|
||||
</h5>
|
||||
<div class="feed">
|
||||
<div hx-get="{% url 'social:events' %}"
|
||||
<div hx-get="{% url 'social:events' %}?type={{ request.GET.type }}"
|
||||
hx-trigger="intersect once delay:0.1s"
|
||||
hx-swap="outerHTML">
|
||||
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
|
||||
|
|
|
@ -132,7 +132,7 @@ class NotificationEvent:
|
|||
self.post = self.post.in_reply_to_post() if self.post else None
|
||||
self.piece = Piece.get_by_post_id(self.post.id) if self.post else None
|
||||
self.item = getattr(self.piece, "item") if hasattr(self.piece, "item") else None
|
||||
if self.piece and self.template in ["liked", "boost", "mentioned"]:
|
||||
if self.piece and self.template in ["liked", "boosted", "mentioned"]:
|
||||
cls = self.piece.__class__.__name__.lower()
|
||||
self.template += "_" + cls
|
||||
|
||||
|
@ -140,7 +140,14 @@ class NotificationEvent:
|
|||
@login_required
|
||||
@require_http_methods(["GET"])
|
||||
def events(request):
|
||||
es = Takahe.get_events(request.user.identity.pk)
|
||||
match request.GET.get("type"):
|
||||
case "follow":
|
||||
types = ["followed", "follow_requested"]
|
||||
case "mention":
|
||||
types = ["mentioned"]
|
||||
case _:
|
||||
types = ["liked", "boosted", "mentioned", "followed", "follow_requested"]
|
||||
es = Takahe.get_events(request.user.identity.pk, types)
|
||||
last = request.GET.get("last")
|
||||
if last:
|
||||
es = es.filter(created__lt=last)
|
||||
|
|
|
@ -944,7 +944,7 @@ class Takahe:
|
|||
a.seen.add(user)
|
||||
|
||||
@staticmethod
|
||||
def get_events(identity_id: int):
|
||||
def get_events(identity_id: int, types):
|
||||
return (
|
||||
TimelineEvent.objects.select_related(
|
||||
"subject_post",
|
||||
|
@ -962,7 +962,7 @@ class Takahe:
|
|||
"subject_post__emojis",
|
||||
)
|
||||
.filter(identity=identity_id)
|
||||
.exclude(type__in=["post", "boost"])
|
||||
.filter(type__in=types)
|
||||
.exclude(subject_identity_id=identity_id)
|
||||
.order_by("-created")
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue