From 24c210e395c33921dca44107b0e8866a87db67bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Wed, 21 May 2025 20:00:01 +0300 Subject: [PATCH] show page 1 even if there is nothing to page --- apps/threads.lua | 2 +- apps/topics.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/threads.lua b/apps/threads.lua index 343011b..fbb7e1b 100644 --- a/apps/threads.lua +++ b/apps/threads.lua @@ -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) diff --git a/apps/topics.lua b/apps/topics.lua index bab6961..548ec6a 100644 --- a/apps/topics.lua +++ b/apps/topics.lua @@ -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([[