diff --git a/src/notifications.c b/src/notifications.c index 847cf64..8c6ee5c 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -23,6 +23,7 @@ #include "string_helpers.h" #include "easprintf.h" #include "status.h" +#include "error.h" // Pages #include "../static/notifications_page.chtml" @@ -134,9 +135,13 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) }; if (mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len) == 0) + { notif_html = construct_notifications(notifs, notifs_len, NULL); + mstdnt_cleanup_notifications(notifs, notifs_len); + } + else + notif_html = construct_error("Couldn't load notifications", NULL); - mstdnt_cleanup_notifications(notifs, notifs_len); } easprintf(&page, data_notifications_page_html, diff --git a/src/timeline.c b/src/timeline.c index 6c8c132..b4c1e27 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -26,13 +26,13 @@ #include "reply.h" #include "navigation.h" #include "query.h" +#include "error.h" #include "string_helpers.h" #include "../static/navigation.chtml" void tl_public(struct session* ssn, mastodont_t* api, int local) { - int cleanup = 0; size_t status_count, statuses_html_count; struct mstdnt_status* statuses = NULL; struct mstdnt_storage storage = { 0 }; @@ -56,14 +56,13 @@ void tl_public(struct session* ssn, mastodont_t* api, int local) if (mastodont_timeline_public(api, &args, &storage, &statuses, &status_count)) { - status_format = "An error occured loading the timeline"; + status_format = construct_error("An error occured loading the timeline", NULL); } else { // Construct statuses into HTML status_format = construct_statuses(statuses, status_count, &statuses_html_count); if (!status_format) status_format = "Error in malloc!"; - cleanup = 1; } // Create post box @@ -95,7 +94,7 @@ void tl_public(struct session* ssn, mastodont_t* api, int local) // Cleanup mastodont_storage_cleanup(&storage); mstdnt_cleanup_statuses(statuses, status_count); - if (cleanup) free(status_format); + if (status_format) free(status_format); if (post_box) free(post_box); if (navigation_box) free(navigation_box); if (output) free(output);