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 <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-05-31 13:22:28 -05:00 committed by Robin Jarry
parent 2551dd1bfa
commit 4985d1bab8
1 changed files with 4 additions and 8 deletions

View File

@ -522,21 +522,17 @@ func countRUE(msgStore *lib.MessageStore) (recent, unread int) {
continue continue
} }
seen := false seen := false
isrecent := false
for _, flag := range msg.Flags { for _, flag := range msg.Flags {
if flag == models.SeenFlag { if flag == models.SeenFlag {
seen = true seen = true
} else if flag == models.RecentFlag { }
isrecent = true if flag == models.RecentFlag {
recent++
} }
} }
if !seen { if !seen {
if isrecent {
recent++
} else {
unread++ unread++
} }
} }
}
return recent, unread return recent, unread
} }