From 0cae9a520c7f3d72ecdabf1fac066f1da943605c Mon Sep 17 00:00:00 2001 From: default Date: Wed, 22 Jan 2025 15:23:37 +0100 Subject: Minor visual tweak. --- html.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 2a02d18..fcf2904 100644 --- a/html.c +++ b/html.c @@ -1855,22 +1855,20 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, } } } - else + if (strcmp(type, "Note") == 0) { - if (level == 0) { - /* is the parent not here? */ - const char *parent = get_in_reply_to(msg); + /* is the parent not here? */ + const char *parent = get_in_reply_to(msg); - if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { - xs_html_add(post_header, - xs_html_tag("div", - xs_html_attr("class", "snac-origin"), - xs_html_text(L("in reply to")), - xs_html_text(" "), - xs_html_tag("a", - xs_html_attr("href", parent), - xs_html_text("»")))); - } + if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { + xs_html_add(post_header, + xs_html_tag("div", + xs_html_attr("class", "snac-origin"), + xs_html_text(L("in reply to")), + xs_html_text(" "), + xs_html_tag("a", + xs_html_attr("href", parent), + xs_html_text("»")))); } } -- cgit v1.2.3 From 0f0e33f5f6f49b9b4055b24761559b11c80da45e Mon Sep 17 00:00:00 2001 From: default Date: Wed, 22 Jan 2025 15:47:21 +0100 Subject: Fixed bug in 'in reply to' checking. --- html.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index fcf2904..a15bd06 100644 --- a/html.c +++ b/html.c @@ -1856,19 +1856,23 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, } } - if (strcmp(type, "Note") == 0) { + if (user && strcmp(type, "Note") == 0) { /* is the parent not here? */ const char *parent = get_in_reply_to(msg); - if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { - xs_html_add(post_header, - xs_html_tag("div", - xs_html_attr("class", "snac-origin"), - xs_html_text(L("in reply to")), - xs_html_text(" "), - xs_html_tag("a", - xs_html_attr("href", parent), - xs_html_text("»")))); + if (!xs_is_null(parent) && *parent) { + xs *md5 = xs_md5_hex(parent, strlen(parent)); + + if (!timeline_here(user, md5)) { + xs_html_add(post_header, + xs_html_tag("div", + xs_html_attr("class", "snac-origin"), + xs_html_text(L("in reply to")), + xs_html_text(" "), + xs_html_tag("a", + xs_html_attr("href", parent), + xs_html_text("»")))); + } } } -- cgit v1.2.3 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 From 95d32cbe7cfbb0321ac37b57ada23b6c268815e2 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 23 Jan 2025 20:17:38 +0100 Subject: Improved notify repetition code. --- html.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index d325063..3fd1e4b 100644 --- a/html.c +++ b/html.c @@ -2993,7 +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) + const char *msg_id = NULL; + + if (xs_is_dict(obj) && (msg_id = xs_dict_get(obj, "id")) && xs_set_add(&rep, msg_id) != 1) continue; const char *actor_id = xs_dict_get(noti, "actor"); -- cgit v1.2.3