From b386d1c2bb0efacea2484b4aa2088c769e048a9c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 3 Dec 2019 17:52:56 +0100 Subject: Fix mailbox view when empty This fixes the second part of #14. References: https://todo.sr.ht/~sircmpwn/koushin/14 --- imap.go | 4 +++- public/mailbox.html | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/imap.go b/imap.go index ca35005..748d5cb 100644 --- a/imap.go +++ b/imap.go @@ -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) diff --git a/public/mailbox.html b/public/mailbox.html index d8c7209..e56efcb 100644 --- a/public/mailbox.html +++ b/public/mailbox.html @@ -15,13 +15,17 @@ {{end}} -

Messages:

- +{{if .Messages}} +

Messages:

+ +{{else}} +

Mailbox is empty.

+{{end}} {{template "foot"}} -- cgit v1.2.3