Skip to content

Commit

Permalink
added SearchQuery.All and ascendingUids.Count check
Browse files Browse the repository at this point in the history
  • Loading branch information
danzuep committed Sep 20, 2023
1 parent eac3bbd commit a9e75b7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -238,8 +239,8 @@ private async Task<IList<IMessageSummary>> 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
{
Expand Down

0 comments on commit a9e75b7

Please sign in to comment.