Browse Source

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
master
Simon Ser 4 years ago
parent
commit
4ab5fb7f65
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
3 changed files with 9 additions and 6 deletions
  1. +1
    -1
      imap.go
  2. +3
    -1
      public/message.html
  3. +5
    -4
      server.go

+ 1
- 1
imap.go 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
}


+ 3
- 1
public/message.html 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>


+ 5
- 4
server.go 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,
})
}



Loading…
Cancel
Save