Manage posts on dashboard and templates fixes

This commit is contained in:
Alphonse Paix
2025-10-03 19:18:15 +02:00
parent ce8c602ddb
commit af9cbdcafb
9 changed files with 65 additions and 55 deletions

View File

@@ -210,11 +210,14 @@ pub async fn load_more(
let posts = get_posts_page(&connection_pool, page)
.await
.context("Could not fetch posts from database.")?;
let count = posts.len();
let count = get_posts_count(&connection_pool)
.await
.context("Could not fetch posts count.")?;
let max_page = get_max_page(count, POSTS_PER_PAGE);
Ok(Html(
PostListTemplate {
posts,
next_page: if count as i64 == POSTS_PER_PAGE {
next_page: if page < max_page {
Some(page + 1)
} else {
None