Small fixes

This commit is contained in:
Aleh Khantsevich
2024-04-30 00:56:00 +02:00
parent b356475741
commit 183873afff
2 changed files with 4 additions and 5 deletions

View File

@@ -53,7 +53,6 @@ namespace Wino.Core.Integration.Threading
var threadItems = (await GetThreadItemsAsync(potentiallyThreadedMails.Select(x => (x.ThreadId, x.AssignedFolder)).ToList(), assignedAccount.Id, sentFolder.Id, draftFolder.Id)) var threadItems = (await GetThreadItemsAsync(potentiallyThreadedMails.Select(x => (x.ThreadId, x.AssignedFolder)).ToList(), assignedAccount.Id, sentFolder.Id, draftFolder.Id))
.GroupBy(x => x.ThreadId); .GroupBy(x => x.ThreadId);
var folderCache = new Dictionary<Guid, MailItemFolder>();
foreach (var threadItem in threadItems) foreach (var threadItem in threadItems)
{ {
if (threadItem.Count() == 1) if (threadItem.Count() == 1)

View File

@@ -195,7 +195,7 @@ namespace Wino.Core.Services
// Avoid DBs calls as possible, storing info in a dictionary. // Avoid DBs calls as possible, storing info in a dictionary.
foreach (var mail in mails) foreach (var mail in mails)
{ {
await PopulateFolderAndAccountAssignment(mail, folderCache, accountCache).ConfigureAwait(false); await LoadAssignedPropertiesWithCacheAsync(mail, folderCache, accountCache).ConfigureAwait(false);
} }
// Remove items that has no assigned account or folder. // Remove items that has no assigned account or folder.
@@ -229,7 +229,7 @@ namespace Wino.Core.Services
// Almost everything already should be in cache from initial population. // Almost everything already should be in cache from initial population.
foreach (var mail in accountThreadedItems) foreach (var mail in accountThreadedItems)
{ {
await PopulateFolderAndAccountAssignment(mail, folderCache, accountCache).ConfigureAwait(false); await LoadAssignedPropertiesWithCacheAsync(mail, folderCache, accountCache).ConfigureAwait(false);
} }
if (accountThreadedItems != null) if (accountThreadedItems != null)
@@ -243,13 +243,13 @@ namespace Wino.Core.Services
return threadedItems; return threadedItems;
// Recursive function to populate folder and account assignments for each mail item. // Recursive function to populate folder and account assignments for each mail item.
async Task PopulateFolderAndAccountAssignment(IMailItem mail, Dictionary<Guid, MailItemFolder> folderCache, Dictionary<Guid, MailAccount> accountCache) async Task LoadAssignedPropertiesWithCacheAsync(IMailItem mail, Dictionary<Guid, MailItemFolder> folderCache, Dictionary<Guid, MailAccount> accountCache)
{ {
if (mail is ThreadMailItem threadMailItem) if (mail is ThreadMailItem threadMailItem)
{ {
foreach (var childMail in threadMailItem.ThreadItems) foreach (var childMail in threadMailItem.ThreadItems)
{ {
await PopulateFolderAndAccountAssignment(childMail, folderCache, accountCache).ConfigureAwait(false); await LoadAssignedPropertiesWithCacheAsync(childMail, folderCache, accountCache).ConfigureAwait(false);
} }
} }