Browse Source

Fix mailbox view when empty

This fixes the second part of #14.

References: https://todo.sr.ht/~sircmpwn/koushin/14
master
Simon Ser 4 years ago
parent
commit
b386d1c2bb
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
2 changed files with 15 additions and 9 deletions
  1. +3
    -1
      imap.go
  2. +12
    -8
      public/mailbox.html

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


+ 12
- 8
public/mailbox.html 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"}}

Loading…
Cancel
Save