summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
Diffstat (limited to 'activities')
-rw-r--r--activities/views/timelines.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/activities/views/timelines.py b/activities/views/timelines.py
index 694039e..753add6 100644
--- a/activities/views/timelines.py
+++ b/activities/views/timelines.py
@@ -173,3 +173,23 @@ class Notifications(ListView):
.order_by("-created")[:50]
.select_related("subject_post", "subject_post__author", "subject_identity")
)
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ # Collapse similar notifications into one
+ events = []
+ for event in context["page_obj"]:
+ if (
+ events
+ and event.type
+ in [
+ TimelineEvent.Types.liked,
+ TimelineEvent.Types.boosted,
+ TimelineEvent.Types.mentioned,
+ ]
+ and event.subject_post_id == events[-1].subject_post_id
+ ):
+ events[-1].collapsed = True
+ events.append(event)
+ context["events"] = events
+ return context