Adding contact details for loaded mails and fixing background notification actions.
This commit is contained in:
@@ -246,7 +246,7 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
await ForceAllAccountSynchronizationsAsync();
|
||||
await MakeSureEnableStartupLaunchAsync();
|
||||
ConfigureBackgroundTasks();
|
||||
await ConfigureBackgroundTasksAsync();
|
||||
}
|
||||
|
||||
private async Task MakeSureEnableStartupLaunchAsync()
|
||||
@@ -289,11 +289,14 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureBackgroundTasks()
|
||||
private async Task ConfigureBackgroundTasksAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// This will only unregister once. Safe to execute multiple times.
|
||||
_backgroundTaskService.UnregisterAllBackgroundTask();
|
||||
|
||||
await _backgroundTaskService.RegisterBackgroundTasksAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -623,7 +626,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ChangeLoadedAccountAsync(IAccountMenuItem clickedBaseAccountMenuItem, bool navigateInbox = true)
|
||||
public async Task ChangeLoadedAccountAsync(IAccountMenuItem clickedBaseAccountMenuItem, bool navigateInbox = true)
|
||||
{
|
||||
if (clickedBaseAccountMenuItem == null) return;
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Wino.Mail.ViewModels.Collections
|
||||
|
||||
if (item is MailItemViewModel itemViewModel)
|
||||
{
|
||||
await ExecuteUIThread(() => { itemViewModel.Update(addedItem); });
|
||||
await ExecuteUIThread(() => { itemViewModel.MailCopy = addedItem; });
|
||||
|
||||
UpdateUniqueIdHashes(itemViewModel, false);
|
||||
UpdateUniqueIdHashes(addedItem, true);
|
||||
@@ -230,7 +230,7 @@ namespace Wino.Mail.ViewModels.Collections
|
||||
UpdateUniqueIdHashes(itemViewModel, false);
|
||||
UpdateUniqueIdHashes(addedItem, true);
|
||||
|
||||
await ExecuteUIThread(() => { itemViewModel.Update(addedItem); });
|
||||
await ExecuteUIThread(() => { itemViewModel.MailCopy = addedItem; });
|
||||
|
||||
shouldExit = true;
|
||||
}
|
||||
@@ -349,7 +349,10 @@ namespace Wino.Mail.ViewModels.Collections
|
||||
UpdateUniqueIdHashes(itemContainer.ItemViewModel, false);
|
||||
}
|
||||
|
||||
itemContainer.ItemViewModel?.Update(updatedMailCopy);
|
||||
if (itemContainer.ItemViewModel != null)
|
||||
{
|
||||
itemContainer.ItemViewModel.MailCopy = updatedMailCopy;
|
||||
}
|
||||
|
||||
UpdateUniqueIdHashes(updatedMailCopy, true);
|
||||
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
public ObservableCollection<MailAttachmentViewModel> IncludedAttachments { get; set; } = [];
|
||||
public ObservableCollection<MailAccount> Accounts { get; set; } = [];
|
||||
public ObservableCollection<AddressInformation> ToItems { get; set; } = [];
|
||||
public ObservableCollection<AddressInformation> CCItems { get; set; } = [];
|
||||
public ObservableCollection<AddressInformation> BCCItems { get; set; } = [];
|
||||
public ObservableCollection<AccountContact> ToItems { get; set; } = [];
|
||||
public ObservableCollection<AccountContact> CCItems { get; set; } = [];
|
||||
public ObservableCollection<AccountContact> BCCItems { get; set; } = [];
|
||||
|
||||
|
||||
public List<EditorToolbarSection> ToolbarSections { get; set; } =
|
||||
@@ -476,7 +476,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAddressInfo(InternetAddressList list, ObservableCollection<AddressInformation> collection)
|
||||
private void LoadAddressInfo(InternetAddressList list, ObservableCollection<AccountContact> collection)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
@@ -509,7 +509,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveAddressInfo(IEnumerable<AddressInformation> addresses, InternetAddressList list)
|
||||
private void SaveAddressInfo(IEnumerable<AccountContact> addresses, InternetAddressList list)
|
||||
{
|
||||
list.Clear();
|
||||
|
||||
@@ -517,7 +517,7 @@ namespace Wino.Mail.ViewModels
|
||||
list.Add(new MailboxAddress(item.Name, item.Address));
|
||||
}
|
||||
|
||||
public async Task<AddressInformation> GetAddressInformationAsync(string tokenText, ObservableCollection<AddressInformation> collection)
|
||||
public async Task<AccountContact> GetAddressInformationAsync(string tokenText, ObservableCollection<AccountContact> collection)
|
||||
{
|
||||
// Get model from the service. This will make sure the name is properly included if there is any record.
|
||||
|
||||
@@ -550,7 +550,7 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
await ExecuteUIThread(() =>
|
||||
{
|
||||
CurrentMailDraftItem.Update(updatedMail);
|
||||
CurrentMailDraftItem.MailCopy = updatedMail;
|
||||
|
||||
DiscardCommand.NotifyCanExecuteChanged();
|
||||
SendCommand.NotifyCanExecuteChanged();
|
||||
|
||||
@@ -11,12 +11,13 @@ namespace Wino.Mail.ViewModels.Data
|
||||
/// </summary>
|
||||
public partial class MailItemViewModel(MailCopy mailCopy) : ObservableObject, IMailItem
|
||||
{
|
||||
public MailCopy MailCopy { get; private set; } = mailCopy;
|
||||
[ObservableProperty]
|
||||
private MailCopy mailCopy = mailCopy;
|
||||
// public MailCopy MailCopy { get; private set; } = mailCopy;
|
||||
|
||||
public Guid UniqueId => ((IMailItem)MailCopy).UniqueId;
|
||||
public string ThreadId => ((IMailItem)MailCopy).ThreadId;
|
||||
public string MessageId => ((IMailItem)MailCopy).MessageId;
|
||||
public string FromName => ((IMailItem)MailCopy).FromName ?? FromAddress;
|
||||
public DateTime CreationDate => ((IMailItem)MailCopy).CreationDate;
|
||||
public string References => ((IMailItem)MailCopy).References;
|
||||
public string InReplyTo => ((IMailItem)MailCopy).InReplyTo;
|
||||
@@ -33,6 +34,12 @@ namespace Wino.Mail.ViewModels.Data
|
||||
set => SetProperty(MailCopy.IsFlagged, value, MailCopy, (u, n) => u.IsFlagged = n);
|
||||
}
|
||||
|
||||
public string FromName
|
||||
{
|
||||
get => string.IsNullOrEmpty(MailCopy.FromName) ? MailCopy.FromAddress : MailCopy.FromName;
|
||||
set => SetProperty(MailCopy.FromName, value, MailCopy, (u, n) => u.FromName = n);
|
||||
}
|
||||
|
||||
public bool IsFocused
|
||||
{
|
||||
get => MailCopy.IsFocused;
|
||||
@@ -93,20 +100,22 @@ namespace Wino.Mail.ViewModels.Data
|
||||
|
||||
public Guid FileId => ((IMailItem)MailCopy).FileId;
|
||||
|
||||
public void Update(MailCopy updatedMailItem)
|
||||
{
|
||||
MailCopy = updatedMailItem;
|
||||
public AccountContact SenderContact => ((IMailItem)MailCopy).SenderContact;
|
||||
|
||||
OnPropertyChanged(nameof(IsRead));
|
||||
OnPropertyChanged(nameof(IsFocused));
|
||||
OnPropertyChanged(nameof(IsFlagged));
|
||||
OnPropertyChanged(nameof(IsDraft));
|
||||
OnPropertyChanged(nameof(DraftId));
|
||||
OnPropertyChanged(nameof(Subject));
|
||||
OnPropertyChanged(nameof(PreviewText));
|
||||
OnPropertyChanged(nameof(FromAddress));
|
||||
OnPropertyChanged(nameof(HasAttachments));
|
||||
}
|
||||
//public void Update(MailCopy updatedMailItem)
|
||||
//{
|
||||
// MailCopy = updatedMailItem;
|
||||
|
||||
// //OnPropertyChanged(nameof(IsRead));
|
||||
// //OnPropertyChanged(nameof(IsFocused));
|
||||
// //OnPropertyChanged(nameof(IsFlagged));
|
||||
// //OnPropertyChanged(nameof(IsDraft));
|
||||
// //OnPropertyChanged(nameof(DraftId));
|
||||
// //OnPropertyChanged(nameof(Subject));
|
||||
// //OnPropertyChanged(nameof(PreviewText));
|
||||
// //OnPropertyChanged(nameof(FromAddress));
|
||||
// //OnPropertyChanged(nameof(HasAttachments));
|
||||
//}
|
||||
|
||||
public IEnumerable<Guid> GetContainingIds() => new[] { UniqueId };
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Wino.Mail.ViewModels.Data
|
||||
public partial class ThreadMailItemViewModel : ObservableObject, IMailItemThread, IComparable<string>, IComparable<DateTime>
|
||||
{
|
||||
public ObservableCollection<IMailItem> ThreadItems => ((IMailItemThread)_threadMailItem).ThreadItems;
|
||||
public AccountContact SenderContact => ((IMailItemThread)_threadMailItem).SenderContact;
|
||||
|
||||
private readonly ThreadMailItem _threadMailItem;
|
||||
|
||||
|
||||
@@ -108,9 +108,9 @@ namespace Wino.Mail.ViewModels
|
||||
private DateTime creationDate;
|
||||
|
||||
|
||||
public ObservableCollection<AddressInformation> ToItems { get; set; } = new ObservableCollection<AddressInformation>();
|
||||
public ObservableCollection<AddressInformation> CCItemsItems { get; set; } = new ObservableCollection<AddressInformation>();
|
||||
public ObservableCollection<AddressInformation> BCCItems { get; set; } = new ObservableCollection<AddressInformation>();
|
||||
public ObservableCollection<AccountContact> ToItems { get; set; } = new ObservableCollection<AccountContact>();
|
||||
public ObservableCollection<AccountContact> CCItemsItems { get; set; } = new ObservableCollection<AccountContact>();
|
||||
public ObservableCollection<AccountContact> BCCItems { get; set; } = new ObservableCollection<AccountContact>();
|
||||
public ObservableCollection<MailAttachmentViewModel> Attachments { get; set; } = new ObservableCollection<MailAttachmentViewModel>();
|
||||
public ObservableCollection<MailOperationMenuItem> MenuItems { get; set; } = new ObservableCollection<MailOperationMenuItem>();
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace Wino.Mail.ViewModels
|
||||
StatePersistenceService.IsReadingMail = false;
|
||||
}
|
||||
|
||||
private void LoadAddressInfo(InternetAddressList list, ObservableCollection<AddressInformation> collection)
|
||||
private void LoadAddressInfo(InternetAddressList list, ObservableCollection<AccountContact> collection)
|
||||
{
|
||||
collection.Clear();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Personalization;
|
||||
@@ -21,6 +22,14 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
private bool isPropChangeDisabled = false;
|
||||
|
||||
// Sample mail copy to use in previewing mail display modes.
|
||||
public MailCopy DemoPreviewMailCopy { get; } = new MailCopy()
|
||||
{
|
||||
FromName = "Sender Name",
|
||||
Subject = "Mail Subject",
|
||||
PreviewText = "Thank you for using Wino Mail. We hope you enjoy the experience.",
|
||||
};
|
||||
|
||||
#region Personalization
|
||||
|
||||
public bool IsSelectedWindowsAccentColor => SelectedAppColor == Colors.LastOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user