show page 1 even if there is nothing to page

This commit is contained in:
Lera Elvoé 2025-05-21 20:00:01 +03:00
parent f18e31811c
commit 24c210e395
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
2 changed files with 2 additions and 2 deletions

View File

@ -72,7 +72,7 @@ app:get("thread", "/:slug", function(self)
local post_count = Posts:count(db.clause({
thread_id = thread.id
}))
self.pages = math.ceil(post_count / POSTS_PER_PAGE)
self.pages = math.max(math.ceil(post_count / POSTS_PER_PAGE), 1)
if self.params.after then
local after_id = tonumber(self.params.after)

View File

@ -73,7 +73,7 @@ app:get("topic", "/:slug", function(self)
}))
self.topic = topic
self.pages = math.ceil(threads_count / THREADS_PER_PAGE)
self.pages = math.max(math.ceil(threads_count / THREADS_PER_PAGE), 1)
self.page = math.max(1, math.min(tonumber(self.params.page) or 1, self.pages))
-- self.threads_list = db.query("SELECT * FROM threads WHERE topic_id = ? ORDER BY is_stickied DESC, created_at DESC", topic.id)
self.threads_list = db.query([[