diff options
Diffstat (limited to 'plugins/base')
-rwxr-xr-x | plugins/base/imap.go | 7 | ||||
-rw-r--r-- | plugins/base/routes.go | 8 |
2 files changed, 7 insertions, 8 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 04ce8d7..db9a3f5 100755 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -344,12 +344,11 @@ func (msg *IMAPMessage) HasFlag(flag string) bool { return false } -func listMessages(conn *imapclient.Client, mboxName string, page, messagesPerPage int) ([]IMAPMessage, error) { - if err := ensureMailboxSelected(conn, mboxName); err != nil { +func listMessages(conn *imapclient.Client, mbox *MailboxStatus, page, messagesPerPage int) ([]IMAPMessage, error) { + if err := ensureMailboxSelected(conn, mbox.Name); err != nil { return nil, err } - mbox := conn.Mailbox() to := int(mbox.Messages) - page*messagesPerPage from := to - messagesPerPage + 1 if from <= 0 { @@ -372,7 +371,7 @@ func listMessages(conn *imapclient.Client, mboxName string, page, messagesPerPag msgs := make([]IMAPMessage, 0, to-from) for msg := range ch { - msgs = append(msgs, IMAPMessage{msg, mboxName}) + msgs = append(msgs, IMAPMessage{msg, mbox.Name}) } if err := <-done; err != nil { diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 9280e1d..d3ff371 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -104,17 +104,17 @@ func handleGetMailbox(ctx *alps.Context) error { if mailboxes, err = listMailboxes(c); err != nil { return err } + if mbox, err = getMailboxStatus(c, mboxName); err != nil { + return err + } if query != "" { msgs, total, err = searchMessages(c, mboxName, query, page, messagesPerPage) } else { - msgs, err = listMessages(c, mboxName, page, messagesPerPage) + msgs, err = listMessages(c, mbox, page, messagesPerPage) } if err != nil { return err } - if mbox, err = getMailboxStatus(c, mboxName); err != nil { - return err - } if mboxName == "INBOX" { inbox = mbox } else { |