~migadu/alps-devel

alps: plugins/base: fix empty last search page v1 APPLIED

~koukas: 1
 plugins/base: fix empty last search page

 1 files changed, 6 insertions(+), 14 deletions(-)
#1033923 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~migadu/alps-devel/patches/43195/mbox | git am -3
Learn more about email & git

[PATCH alps] plugins/base: fix empty last search page Export this patch

From: Konstantinos Koukas <contact@koukas.org>

Fix an empty search page appearing when the total number of search
results is a multiple of the number of messages per page.
---
 plugins/base/routes.go | 20 ++++++--------------
 1 file 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{
-- 
2.38.5
alps/patches/.build.yml: SUCCESS in 1m13s

[plugins/base: fix empty last search page][0] from [~koukas][1]

[0]: https://lists.sr.ht/~migadu/alps-devel/patches/43195
[1]: mailto:contact@koukas.org

✓ #1033923 SUCCESS alps/patches/.build.yml https://builds.sr.ht/~migadu/job/1033923
Nice cleanup! Pushed, thanks!