From 4ab5fb7f65fe8d8f0b291dbead9f0134a28eaba2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 3 Dec 2019 20:06:43 +0100 Subject: [PATCH] Make message view's Back link set the mailbox page This allows to go back and forth between the mailbox view and the message view. References: https://todo.sr.ht/~sircmpwn/koushin/22 --- imap.go | 2 +- public/message.html | 4 +++- server.go | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/imap.go b/imap.go index 9c83fc7..9081689 100644 --- a/imap.go +++ b/imap.go @@ -213,7 +213,7 @@ func listMessages(conn *imapclient.Client, mboxName string, page int) ([]imapMes mbox := conn.Mailbox() to := int(mbox.Messages) - page*messagesPerPage - from := to - messagesPerPage + from := to - messagesPerPage + 1 if from <= 0 { from = 1 } diff --git a/public/message.html b/public/message.html index 5c18bd0..f653057 100644 --- a/public/message.html +++ b/public/message.html @@ -3,7 +3,9 @@

koushin

- Back + + Back +

diff --git a/server.go b/server.go index 93da487..021ecff 100644 --- a/server.go +++ b/server.go @@ -203,10 +203,11 @@ func handleGetPart(ctx *context, raw bool) error { } return ctx.Render(http.StatusOK, "message.html", map[string]interface{}{ - "Mailbox": mbox, - "Message": msg, - "Body": body, - "PartPath": partPathString, + "Mailbox": mbox, + "Message": msg, + "Body": body, + "PartPath": partPathString, + "MailboxPage": (mbox.Messages - msg.SeqNum) / messagesPerPage, }) }