From 4985d1bab8996a995bd93abe120835320e3c7d82 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 31 May 2022 13:22:28 -0500 Subject: [PATCH] fix: rue string count accuracy The countRUE function was inaccurately counting flags. If a message was unread and recent, it was only counted as recent. The two flags are not mutually exclusive. A previous count for a mailbox with 1 recent, 1 unread, and 5 existing would be : 1/0/5 An accurate count of this state would be: 1/1/5 This patch fixes the count. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/dirlist.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/widgets/dirlist.go b/widgets/dirlist.go index ca0f6c1..99ffe19 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -522,20 +522,16 @@ func countRUE(msgStore *lib.MessageStore) (recent, unread int) { continue } seen := false - isrecent := false for _, flag := range msg.Flags { if flag == models.SeenFlag { seen = true - } else if flag == models.RecentFlag { - isrecent = true + } + if flag == models.RecentFlag { + recent++ } } if !seen { - if isrecent { - recent++ - } else { - unread++ - } + unread++ } } return recent, unread