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
This commit is contained in:
Simon Ser 2019-12-03 20:06:43 +01:00
parent a2349050d0
commit 4ab5fb7f65
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 9 additions and 6 deletions

View file

@ -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
}

View file

@ -3,7 +3,9 @@
<h1>koushin</h1>
<p>
<a href="/mailbox/{{.Mailbox.Name | pathescape}}">Back</a>
<a href="/mailbox/{{.Mailbox.Name | pathescape}}?page={{.MailboxPage}}">
Back
</a>
</p>
<h2>

View file

@ -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,
})
}