aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/base/routes.go
diff options
context:
space:
mode:
authorLibravatarLibravatar Konstantinos Koukas <[email protected]> 2023-08-02 13:21:03 +0300
committerLibravatarLibravatar Simon Ser <[email protected]> 2023-08-02 15:56:56 +0200
commit8a6dd176040060b5beac5cacc466682d1c6942fe (patch)
tree3831c2fef66a9bae9071281b62b33e41d117821d /plugins/base/routes.go
parenta80b550593428fbb18cbcd0304f6373f9ba61eed (diff)
downloadalps-8a6dd176040060b5beac5cacc466682d1c6942fe.tar.gz
alps-8a6dd176040060b5beac5cacc466682d1c6942fe.tar.bz2
alps-8a6dd176040060b5beac5cacc466682d1c6942fe.zip
plugins/base: fix empty last search page
Fix an empty search page appearing when the total number of search results is a multiple of the number of messages per page.
Diffstat (limited to 'plugins/base/routes.go')
-rw-r--r--plugins/base/routes.go20
1 files changed, 6 insertions, 14 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index c04b9ef..5176775 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -261,6 +261,7 @@ func handleGetMailbox(ctx *alps.Context) error {
msgs, total, err = searchMessages(c, mbox.Name(), query, page, messagesPerPage)
} else {
msgs, err = listMessages(c, mbox, page, messagesPerPage)
+ total = int(*mbox.NumMessages)
}
if err != nil {
return err
@@ -272,20 +273,11 @@ func handleGetMailbox(ctx *alps.Context) error {
}
prevPage, nextPage := -1, -1
- if query != "" {
- if page > 0 {
- prevPage = page - 1
- }
- if (page+1)*messagesPerPage <= total {
- nextPage = page + 1
- }
- } else {
- if page > 0 {
- prevPage = page - 1
- }
- if (page+1)*messagesPerPage < int(*mbox.NumMessages) {
- nextPage = page + 1
- }
+ if page > 0 {
+ prevPage = page - 1
+ }
+ if (page+1)*messagesPerPage < total {
+ nextPage = page + 1
}
return ctx.Render(http.StatusOK, "mailbox.html", &MailboxRenderData{