From a9e75b716c303e549ef698e651ae50e2ed6200aa Mon Sep 17 00:00:00 2001 From: Daniel Collingwood <82693586+danzuep@users.noreply.github.com> Date: Wed, 20 Sep 2023 08:18:50 +0800 Subject: [PATCH] added SearchQuery.All and ascendingUids.Count check --- .../Services/MailFolderReader.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs index ec4834b..5cb2f96 100644 --- a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs +++ b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs @@ -136,7 +136,8 @@ public IMailReader Range(UniqueId start, ushort batchSize = 0, bool continuous = public IMailReader Query(SearchQuery searchQuery) { _searchQuery = searchQuery; - _take = _queryAmount; + if (searchQuery != SearchQuery.All) + _take = _queryAmount; return this; } @@ -238,8 +239,8 @@ private async Task> GetMessageSummariesAsync(IMailFolder var ascendingUids = noFilter ? searchResults.UniqueIds : new UniqueIdSet(filteredUids, SortOrder.Ascending); var messageSummaries = await mailFolder.FetchAsync(ascendingUids, filter, cancellationToken).ConfigureAwait(false); - filteredSummaries = messageSummaries.Count > _queryAmount ? messageSummaries : - messageSummaries.Where(m => ascendingUids.Contains(m.UniqueId)).ToList(); + filteredSummaries = messageSummaries.Count > _queryAmount || messageSummaries.Count == ascendingUids.Count ? + messageSummaries : messageSummaries.Where(m => ascendingUids.Contains(m.UniqueId)).ToList(); } else {