Manage posts on dashboard and templates fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user