From 684978e77da62c02d99eb8310b8cc75fdbca9888 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Wed, 18 Dec 2019 06:33:56 +0100 Subject: widgets: add msgInfoFromUids helper --- widgets/common.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 widgets/common.go (limited to 'widgets/common.go') diff --git a/widgets/common.go b/widgets/common.go new file mode 100644 index 00000000..e1cee05a --- /dev/null +++ b/widgets/common.go @@ -0,0 +1,20 @@ +package widgets + +import ( + "fmt" + + "git.sr.ht/~sircmpwn/aerc/lib" + "git.sr.ht/~sircmpwn/aerc/models" +) + +func msgInfoFromUids(store *lib.MessageStore, uids []uint32) ([]*models.MessageInfo, error) { + infos := make([]*models.MessageInfo, len(uids)) + for i, uid := range uids { + var ok bool + infos[i], ok = store.Messages[uid] + if !ok { + return nil, fmt.Errorf("uid not found") + } + } + return infos, nil +} -- cgit