Fix mailbox view when empty

This fixes the second part of #14.

References: https://todo.sr.ht/~sircmpwn/koushin/14
This commit is contained in:
Simon Ser 2019-12-03 17:52:56 +01:00
parent b7be271560
commit b386d1c2bb
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 15 additions and 9 deletions

View file

@ -216,7 +216,9 @@ func listMessages(conn *imapclient.Client, mboxName string) ([]imapMessage, erro
mbox := conn.Mailbox()
from := uint32(1)
to := mbox.Messages
if mbox.Messages > n {
if mbox.Messages == 0 {
return nil, nil
} else if mbox.Messages > n {
from = mbox.Messages - n
}
seqSet := new(imap.SeqSet)

View file

@ -15,13 +15,17 @@
{{end}}
</ul>
<p>Messages:</p>
<ul>
{{range .Messages}}
<li><a href="/message/{{$.Mailbox.Name | pathescape}}/{{.Uid}}?part={{.TextPartName}}">
{{.Envelope.Subject}}
</a></li>
{{end}}
</ul>
{{if .Messages}}
<p>Messages:</p>
<ul>
{{range .Messages}}
<li><a href="/message/{{$.Mailbox.Name | pathescape}}/{{.Uid}}?part={{.TextPartName}}">
{{.Envelope.Subject}}
</a></li>
{{end}}
</ul>
{{else}}
<p>Mailbox is empty.</p>
{{end}}
{{template "foot"}}