From f87d88374e22f8d6c6155ba8c2cdbc9e84776b47 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Wed, 27 Apr 2022 15:41:16 +0000 Subject: [PATCH] Bookmarks and favourites page FossilOrigin-Name: a674d158792e9dd0a67e70281827ecad172fb281cf27eb02e8e72ac9fe52618d --- src/account.c | 5 +---- src/base_page.c | 4 ++-- src/login.c | 2 +- src/notifications.c | 12 +++++++++++- static/navigation.html | 6 +++--- static/notifications_page.html | 1 + 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/account.c b/src/account.c index 2932a3b..d4ec25a 100644 --- a/src/account.c +++ b/src/account.c @@ -363,7 +363,6 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat char* start_id; struct mstdnt_bookmarks_args args = { - .with_muted = 0, .max_id = ssn->post.max_id, .since_id = NULL, .min_id = ssn->post.min_id, @@ -428,10 +427,8 @@ void content_account_favourites(struct session* ssn, mastodont_t* api, char** da *page = NULL; char* start_id; - struct mstdnt_timeline_args args = { - .with_muted = 0, + struct mstdnt_favourites_args args = { .max_id = ssn->post.max_id, - .since_id = NULL, .min_id = ssn->post.min_id, .limit = 20, }; diff --git a/src/base_page.c b/src/base_page.c index 6a7f2ef..c033fe7 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -105,10 +105,10 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t* L10N[locale][L10N_LISTS], CAT_TEXT(page->category, BASE_CAT_FAVOURITES), config_url_prefix, - L10N[locale][L10N_LISTS], + L10N[locale][L10N_FAVOURITES], CAT_TEXT(page->category, BASE_CAT_BOOKMARKS), config_url_prefix, - L10N[locale][L10N_LISTS], + L10N[locale][L10N_BOOKMARKS], CAT_TEXT(page->category, BASE_CAT_DIRECT), config_url_prefix, L10N[locale][L10N_DIRECT], diff --git a/src/login.c b/src/login.c index b07c9af..dc1ca7b 100644 --- a/src/login.c +++ b/src/login.c @@ -67,7 +67,7 @@ void content_login(struct session* ssn, mastodont_t* api, char** data) }; if (mastodont_obtain_oauth_token(api, &args_token, &oauth_store, - &token) != 0) + &token) != 0 && oauth_store.error) { error = construct_error(oauth_store.error, E_ERROR, 1, NULL); } diff --git a/src/notifications.c b/src/notifications.c index 308587d..d12b275 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -23,6 +23,7 @@ #include "base_page.h" #include "string_helpers.h" #include "easprintf.h" +#include "navigation.h" #include "status.h" #include "error.h" #include "../config.h" @@ -173,6 +174,8 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) struct mstdnt_storage storage; struct mstdnt_notification* notifs; size_t notifs_len; + char* start_id; + char* navigation_box = NULL; if (ssn->cookies.logged_in) { @@ -193,6 +196,11 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) { notif_html = construct_notifications(api, notifs, notifs_len, NULL); mstdnt_cleanup_notifications(notifs, notifs_len); + start_id = ssn->post.start_id ? ssn->post.start_id : notifs[0].id; + navigation_box = construct_navigation_box(start_id, + notifs[0].id, + notifs[notifs_len-1].id, + NULL); } else notif_html = construct_error(storage.error, E_NOTICE, 1, NULL); @@ -200,7 +208,8 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) } easprintf(&page, data_notifications_page_html, - notif_html ? notif_html : "Not logged in"); + notif_html ? notif_html : "", + navigation_box); struct base_page b = { .category = BASE_CAT_NOTIFICATIONS, @@ -212,6 +221,7 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) // Output render_base_page(&b, ssn, api); if (notif_html) free(notif_html); + if (navigation_box) free(navigation_box); if (page) free(page); } diff --git a/static/navigation.html b/static/navigation.html index 655a2be..8463cd5 100644 --- a/static/navigation.html +++ b/static/navigation.html @@ -1,7 +1,7 @@