From 27b25174e2f0249a6a1d4ba45b70f8504b63ffb1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 31 Mar 2019 12:14:37 -0400 Subject: Make the message viewer real, part one --- lib/msgstore.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/msgstore.go b/lib/msgstore.go index 64b1638..2169b2e 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -67,7 +67,6 @@ func (store *MessageStore) FetchHeaders(uids []uint32, } func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) { - // TODO: this could be optimized by pre-allocating toFetch and trimming it // at the end. In practice we expect to get most messages back in one frame. var toFetch imap.SeqSet @@ -89,6 +88,21 @@ func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) { } } +func (store *MessageStore) FetchBodyPart( + uid uint32, part int, cb func(io.Reader)) { + + store.worker.PostAction(&types.FetchMessageBodyPart{ + Uid: uid, + Part: part, + }, func(resp types.WorkerMessage) { + msg, ok := resp.(*types.MessageBodyPart) + if !ok { + return + } + cb(msg.Reader) + }) +} + func (store *MessageStore) merge( to *types.MessageInfo, from *types.MessageInfo) { -- cgit v1.2.3