From 0394f835e45975b9a82b0b009de2471e55a6cb7a Mon Sep 17 00:00:00 2001 From: default Date: Thu, 23 Jan 2025 20:09:22 +0100 Subject: Added some code to supress repeated notifications. --- html.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index a15bd06..d325063 100644 --- a/html.c +++ b/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", -- cgit v1.2.3