Asynchronously load correct contact data for composer.
This commit is contained in:
@@ -438,7 +438,7 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
var renderModel = _mimeFileService.GetMailRenderModel(replyingMime, mimeFilePath);
|
||||
|
||||
await ExecuteUIThread(() =>
|
||||
await ExecuteUIThread(async () =>
|
||||
{
|
||||
// Extract information
|
||||
|
||||
@@ -448,9 +448,9 @@ namespace Wino.Mail.ViewModels
|
||||
CCItems.Clear();
|
||||
BCCItems.Clear();
|
||||
|
||||
LoadAddressInfo(replyingMime.To, ToItems);
|
||||
LoadAddressInfo(replyingMime.Cc, CCItems);
|
||||
LoadAddressInfo(replyingMime.Bcc, BCCItems);
|
||||
await LoadAddressInfoAsync(replyingMime.To, ToItems);
|
||||
await LoadAddressInfoAsync(replyingMime.Cc, CCItems);
|
||||
await LoadAddressInfoAsync(replyingMime.Bcc, BCCItems);
|
||||
|
||||
LoadAttachments();
|
||||
|
||||
@@ -476,14 +476,19 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAddressInfo(InternetAddressList list, ObservableCollection<AccountContact> collection)
|
||||
private async Task LoadAddressInfoAsync(InternetAddressList list, ObservableCollection<AccountContact> collection)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item is MailboxAddress mailboxAddress)
|
||||
collection.Add(mailboxAddress.ToAddressInformation());
|
||||
{
|
||||
var foundContact = await ContactService.GetAddressInformationByAddressAsync(mailboxAddress.Address).ConfigureAwait(false)
|
||||
?? new AccountContact() { Name = mailboxAddress.Name, Address = mailboxAddress.Address };
|
||||
|
||||
await ExecuteUIThread(() => { collection.Add(foundContact); });
|
||||
}
|
||||
else if (item is GroupAddress groupAddress)
|
||||
LoadAddressInfo(groupAddress.Members, collection);
|
||||
await LoadAddressInfoAsync(groupAddress.Members, collection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +526,8 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
// Get model from the service. This will make sure the name is properly included if there is any record.
|
||||
|
||||
var info = await ContactService.GetAddressInformationByAddressAsync(tokenText);
|
||||
var info = await ContactService.GetAddressInformationByAddressAsync(tokenText)
|
||||
?? new AccountContact() { Name = tokenText, Address = tokenText };
|
||||
|
||||
// Don't add if there is already that address in the collection.
|
||||
if (collection.Any(a => a.Address == info.Address))
|
||||
|
||||
Reference in New Issue
Block a user