diff options
| -rw-r--r-- | html.c | 46 |
1 files changed, 36 insertions, 10 deletions
| @@ -2967,8 +2967,8 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2967 | xs_html_attr("class", "snac-posts")); | 2967 | xs_html_attr("class", "snac-posts")); |
| 2968 | xs_html_add(body, posts); | 2968 | xs_html_add(body, posts); |
| 2969 | 2969 | ||
| 2970 | xs_set rep; | 2970 | /* dict to store previous notification labels */ |
| 2971 | xs_set_init(&rep); | 2971 | xs *admiration_labels = xs_dict_new(); |
| 2972 | 2972 | ||
| 2973 | const xs_str *v; | 2973 | const xs_str *v; |
| 2974 | 2974 | ||
| @@ -2995,8 +2995,8 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2995 | 2995 | ||
| 2996 | const char *msg_id = NULL; | 2996 | const char *msg_id = NULL; |
| 2997 | 2997 | ||
| 2998 | if (xs_is_dict(obj) && (msg_id = xs_dict_get(obj, "id")) && xs_set_add(&rep, msg_id) != 1) | 2998 | if (xs_is_dict(obj)) |
| 2999 | continue; | 2999 | msg_id = xs_dict_get(obj, "id"); |
| 3000 | 3000 | ||
| 3001 | const char *actor_id = xs_dict_get(noti, "actor"); | 3001 | const char *actor_id = xs_dict_get(noti, "actor"); |
| 3002 | xs *actor = NULL; | 3002 | xs *actor = NULL; |
| @@ -3030,9 +3030,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3030 | 3030 | ||
| 3031 | xs *s_date = xs_crop_i(xs_dup(date), 0, 10); | 3031 | xs *s_date = xs_crop_i(xs_dup(date), 0, 10); |
| 3032 | 3032 | ||
| 3033 | xs_html *entry = xs_html_tag("div", | 3033 | xs_html *this_html_label = xs_html_container( |
| 3034 | xs_html_attr("class", "snac-post-with-desc"), | ||
| 3035 | xs_html_tag("p", | ||
| 3036 | xs_html_tag("b", | 3034 | xs_html_tag("b", |
| 3037 | xs_html_text(label), | 3035 | xs_html_text(label), |
| 3038 | xs_html_text(" by "), | 3036 | xs_html_text(" by "), |
| @@ -3043,7 +3041,37 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3043 | xs_html_tag("time", | 3041 | xs_html_tag("time", |
| 3044 | xs_html_attr("class", "dt-published snac-pubdate"), | 3042 | xs_html_attr("class", "dt-published snac-pubdate"), |
| 3045 | xs_html_attr("title", date), | 3043 | xs_html_attr("title", date), |
| 3046 | xs_html_text(s_date)))); | 3044 | xs_html_text(s_date))); |
| 3045 | |||
| 3046 | xs_html *html_label = NULL; | ||
| 3047 | |||
| 3048 | if (xs_is_string(msg_id)) { | ||
| 3049 | const xs_val *prev_label = xs_dict_get(admiration_labels, msg_id); | ||
| 3050 | |||
| 3051 | if (xs_type(prev_label) == XSTYPE_DATA) { | ||
| 3052 | /* there is a previous list of admiration labels! */ | ||
| 3053 | xs_data_get(&html_label, prev_label); | ||
| 3054 | |||
| 3055 | xs_html_add(html_label, | ||
| 3056 | xs_html_sctag("br", NULL), | ||
| 3057 | this_html_label); | ||
| 3058 | |||
| 3059 | continue; | ||
| 3060 | } | ||
| 3061 | } | ||
| 3062 | |||
| 3063 | xs_html *entry = NULL; | ||
| 3064 | |||
| 3065 | html_label = xs_html_tag("p", | ||
| 3066 | this_html_label); | ||
| 3067 | |||
| 3068 | /* store in the admiration labels dict */ | ||
| 3069 | xs *pl = xs_data_new(&html_label, sizeof(html_label)); | ||
| 3070 | admiration_labels = xs_dict_set(admiration_labels, msg_id, pl); | ||
| 3071 | |||
| 3072 | entry = xs_html_tag("div", | ||
| 3073 | xs_html_attr("class", "snac-post-with-desc"), | ||
| 3074 | html_label); | ||
| 3047 | 3075 | ||
| 3048 | if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0 || strcmp(type, "Block") == 0) { | 3076 | if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0 || strcmp(type, "Block") == 0) { |
| 3049 | xs_html_add(entry, | 3077 | xs_html_add(entry, |
| @@ -3111,8 +3139,6 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3111 | } | 3139 | } |
| 3112 | } | 3140 | } |
| 3113 | 3141 | ||
| 3114 | xs_set_free(&rep); | ||
| 3115 | |||
| 3116 | if (noti_new == NULL && noti_seen == NULL) | 3142 | if (noti_new == NULL && noti_seen == NULL) |
| 3117 | xs_html_add(body, | 3143 | xs_html_add(body, |
| 3118 | xs_html_tag("h2", | 3144 | xs_html_tag("h2", |