From 183873afff6b79dd63fa6e18d30a3b443e8b208a Mon Sep 17 00:00:00 2001 From: Aleh Khantsevich Date: Tue, 30 Apr 2024 00:56:00 +0200 Subject: [PATCH] Small fixes --- Wino.Core/Integration/Threading/APIThreadingStrategy.cs | 1 - Wino.Core/Services/MailService.cs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Wino.Core/Integration/Threading/APIThreadingStrategy.cs b/Wino.Core/Integration/Threading/APIThreadingStrategy.cs index c36e8fed..f1258f9d 100644 --- a/Wino.Core/Integration/Threading/APIThreadingStrategy.cs +++ b/Wino.Core/Integration/Threading/APIThreadingStrategy.cs @@ -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)) .GroupBy(x => x.ThreadId); - var folderCache = new Dictionary(); foreach (var threadItem in threadItems) { if (threadItem.Count() == 1) diff --git a/Wino.Core/Services/MailService.cs b/Wino.Core/Services/MailService.cs index 0c6b24e9..18be6ec9 100644 --- a/Wino.Core/Services/MailService.cs +++ b/Wino.Core/Services/MailService.cs @@ -195,7 +195,7 @@ namespace Wino.Core.Services // Avoid DBs calls as possible, storing info in a dictionary. 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. @@ -229,7 +229,7 @@ namespace Wino.Core.Services // Almost everything already should be in cache from initial population. foreach (var mail in accountThreadedItems) { - await PopulateFolderAndAccountAssignment(mail, folderCache, accountCache).ConfigureAwait(false); + await LoadAssignedPropertiesWithCacheAsync(mail, folderCache, accountCache).ConfigureAwait(false); } if (accountThreadedItems != null) @@ -243,13 +243,13 @@ namespace Wino.Core.Services return threadedItems; // Recursive function to populate folder and account assignments for each mail item. - async Task PopulateFolderAndAccountAssignment(IMailItem mail, Dictionary folderCache, Dictionary accountCache) + async Task LoadAssignedPropertiesWithCacheAsync(IMailItem mail, Dictionary folderCache, Dictionary accountCache) { if (mail is ThreadMailItem threadMailItem) { foreach (var childMail in threadMailItem.ThreadItems) { - await PopulateFolderAndAccountAssignment(childMail, folderCache, accountCache).ConfigureAwait(false); + await LoadAssignedPropertiesWithCacheAsync(childMail, folderCache, accountCache).ConfigureAwait(false); } }