From 0e20bbc28ed3d5b7ac7b0e7109d4696089a670fe Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 15 Feb 2022 10:25:46 -0500 Subject: [PATCH] perf(mail): perform IMAP STATUS command to fetch unseen msgs count --- SoObjects/Mailer/SOGoMailFolder.m | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 3cc47114d..5855b5550 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2021 Inverse inc. + Copyright (C) 2009-2022 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo. @@ -946,26 +946,12 @@ static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids) - (unsigned int) unseenCount { NSDictionary *imapResult; - NGImap4Connection *connection; - NGImap4Client *client; - EOQualifier *searchQualifier; - NSArray *searchResult; unsigned int unseen; - connection = [self imap4Connection]; - client = [connection client]; - - if ([connection selectFolder: [self imap4URL]]) - { - searchQualifier - = [EOQualifier qualifierWithQualifierFormat: @"flags = %@ AND not flags = %@", - @"unseen", @"deleted"]; - imapResult = [client searchWithQualifier: searchQualifier]; - searchResult = [[imapResult objectForKey: @"RawResponse"] objectForKey: @"search"]; - unseen = [searchResult count]; - } - else - unseen = 0; + unseen = 0; + imapResult = [self statusForFlags: [NSArray arrayWithObject: @"unseen"]]; + if (imapResult) + unseen = [[imapResult valueForKey: @"unseen"] intValue]; return unseen; }