From cdd8ec2e76aca1f606aafc97176493e055295261 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Sun, 20 Mar 2022 06:59:50 +0000 Subject: [PATCH] Notifications (compact) FossilOrigin-Name: f582fe922169ff4c8bc4ce57f8d1a82ffe201041b4bb63d037f16dbb081c3a25 --- dist/treebird20.css | 35 +++++++++++++++++++++++++++++++- src/base_page.c | 10 ++++----- src/notifications.c | 17 ++++++++++++++-- static/notification_compact.html | 15 +++++++++++++- static/notifications.html | 4 ++-- 5 files changed, 70 insertions(+), 11 deletions(-) diff --git a/dist/treebird20.css b/dist/treebird20.css index 4c7fdb9..e399b4d 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -195,6 +195,39 @@ ul li:first-child a.sidebarbtn border-left: 1px solid #cacaca; } +/**************************** + * Notifications * + ***************************/ +.notification +{ + border-bottom: 1px solid #dadada; +} + +.pfp-compact-td img +{ + border-radius: 3px; +} + +.notification-compact .notification-info +{ + font-size: 12px; + padding-left: 2px; + padding-right: 2px; +} + +.notification-compact .notification-content +{ + color: #808080; + font-size: 12px; + padding: 2px 0 2px 0; +} + +.notification-compact .notification-stats +{ + color: #500000; + font-size: 10px; +} + /*************************** * Statuses * **************************/ @@ -244,7 +277,7 @@ ul li:first-child a.sidebarbtn margin: 0 5px 0px; min-width: 0; width: auto; - padding: 5px 5px 0 5px; + padding: 0 5px 0 5px; display: flex; } diff --git a/src/base_page.c b/src/base_page.c index 33d904e..4ac1a2b 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -59,14 +59,14 @@ void render_base_page(struct base_page* page, mastodont_t* api) .max_id = NULL, .min_id = NULL, .since_id = NULL, - .offset = 2, - .limit = 15, + .offset = 0, + .limit = 20, }; - mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len); - sidebar_str = construct_notifications_compact(notifs, notifs_len, NULL); + if (mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len) == 0) + sidebar_str = construct_notifications_compact(notifs, notifs_len, NULL); - //mstdnt_cleanup_notifications(notifs, notifs_len); + mstdnt_cleanup_notifications(notifs, notifs_len); } char* data; diff --git a/src/notifications.c b/src/notifications.c index 6fa5fd8..864630e 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "notifications.h" #include "base_page.h" #include "string_helpers.h" @@ -36,12 +37,24 @@ char* construct_notification(struct mstdnt_notification* notif, int* size) char* construct_notification_compact(struct mstdnt_notification* notif, int* size) { char* notif_html; + char* notif_stats; + + easprintf(¬if_stats, "%d - %d - %d", + notif->status->replies_count, + notif->status->reblogs_count, + notif->status->favourites_count); + size_t s = easprintf(¬if_html, data_notification_compact_html, - notif->id); + notif->account->avatar, + notif->account->display_name, + "interacted", + notif->status->content, + notif_stats); if (size) *size = s; - + + if (notif_stats) free(notif_stats); return notif_html; } diff --git a/static/notification_compact.html b/static/notification_compact.html index 042e93e..c46a30f 100644 --- a/static/notification_compact.html +++ b/static/notification_compact.html @@ -1 +1,14 @@ -%s
+ + + + + +
+ + +
+ %s %s +
+
%s
+
%s
+
diff --git a/static/notifications.html b/static/notifications.html index 1de5c6a..43e63ba 100644 --- a/static/notifications.html +++ b/static/notifications.html @@ -1,3 +1,3 @@ -
    +
    -
+