Browse Source

Added some code to supress repeated notifications.

default 2 months ago
parent
commit
0394f835e4
1 changed files with 10 additions and 2 deletions
  1. 10 2
      html.c

+ 10 - 2
html.c

@@ -2967,9 +2967,12 @@ xs_str *html_notifications(snac *user, int skip, int show)
         xs_html_attr("class", "snac-posts"));
     xs_html_add(body, posts);
 
-    xs_list *p = n_list;
+    xs_set rep;
+    xs_set_init(&rep);
+
     const xs_str *v;
-    while (xs_list_iter(&p, &v)) {
+
+    xs_list_foreach(n_list, v) {
         xs *noti = notify_get(user, v);
 
         if (noti == NULL)
@@ -2990,6 +2993,9 @@ xs_str *html_notifications(snac *user, int skip, int show)
 
         object_get(id, &obj);
 
+        if (xs_set_add(&rep, xs_dict_get(obj, "id")) != 1)
+            continue;
+
         const char *actor_id = xs_dict_get(noti, "actor");
         xs *actor = NULL;
 
@@ -3103,6 +3109,8 @@ xs_str *html_notifications(snac *user, int skip, int show)
         }
     }
 
+    xs_set_free(&rep);
+
     if (noti_new == NULL && noti_seen == NULL)
         xs_html_add(body,
             xs_html_tag("h2",