Remove sqlite base64 contact store from AccountContact.
This commit is contained in:
@@ -22,6 +22,7 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
|
||||
private readonly IContactService _contactService;
|
||||
private readonly IMailDialogService _dialogService;
|
||||
private readonly IContactPictureFileService _contactPictureFileService;
|
||||
|
||||
private CancellationTokenSource _searchDebounceCancellationTokenSource;
|
||||
private int _currentOffset = 0;
|
||||
@@ -60,10 +61,11 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
public ObservableCollection<AccountContactViewModel> Contacts { get; } = new();
|
||||
public ObservableCollection<AccountContactViewModel> SelectedContacts { get; } = new();
|
||||
|
||||
public ContactsPageViewModel(IContactService contactService, IMailDialogService dialogService)
|
||||
public ContactsPageViewModel(IContactService contactService, IMailDialogService dialogService, IContactPictureFileService contactPictureFileService)
|
||||
{
|
||||
_contactService = contactService;
|
||||
_dialogService = dialogService;
|
||||
_contactPictureFileService = contactPictureFileService;
|
||||
|
||||
Contacts.CollectionChanged += ContactsCollectionChanged;
|
||||
}
|
||||
@@ -195,9 +197,9 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
{
|
||||
var newContact = await _contactService.CreateNewContactAsync(result.Address, result.Name);
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Base64ContactPicture))
|
||||
if (result.ContactPictureFileId.HasValue)
|
||||
{
|
||||
newContact.Base64ContactPicture = result.Base64ContactPicture;
|
||||
newContact.ContactPictureFileId = result.ContactPictureFileId;
|
||||
await _contactService.UpdateContactAsync(newContact);
|
||||
}
|
||||
|
||||
@@ -230,7 +232,7 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
try
|
||||
{
|
||||
contact.Name = result.Name;
|
||||
contact.Base64ContactPicture = result.Base64ContactPicture;
|
||||
contact.ContactPictureFileId = result.ContactPictureFileId;
|
||||
contact.IsOverridden = result.IsOverridden;
|
||||
|
||||
await _contactService.UpdateContactAsync(contact);
|
||||
@@ -382,9 +384,14 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
if (files?.Any() == true)
|
||||
{
|
||||
var file = files.First();
|
||||
var base64Image = Convert.ToBase64String(file.Data);
|
||||
|
||||
contact.Base64ContactPicture = base64Image;
|
||||
if (contact.ContactPictureFileId.HasValue)
|
||||
await _contactPictureFileService.DeleteContactPictureAsync(contact.ContactPictureFileId.Value);
|
||||
|
||||
contact.ContactPictureFileId = await _contactPictureFileService
|
||||
.SaveContactPictureAsync(file.Data)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await _contactService.UpdateContactAsync(contact);
|
||||
await RefreshContactInUiAsync(contact);
|
||||
|
||||
@@ -432,7 +439,7 @@ public partial class ContactsPageViewModel : MailBaseViewModel
|
||||
{
|
||||
Address = contact.Address,
|
||||
Name = contact.Name,
|
||||
Base64ContactPicture = contact.Base64ContactPicture,
|
||||
ContactPictureFileId = contact.ContactPictureFileId,
|
||||
IsRootContact = contact.IsRootContact,
|
||||
IsOverridden = contact.IsOverridden
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@ public partial class AccountContactViewModel : ObservableObject, IMailItemDispla
|
||||
public string Address { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid? ContactPictureFileId { get; set; }
|
||||
public string Base64ContactPicture { get; set; }
|
||||
public bool IsRootContact { get; set; }
|
||||
public bool IsOverridden { get; set; }
|
||||
|
||||
@@ -22,7 +21,6 @@ public partial class AccountContactViewModel : ObservableObject, IMailItemDispla
|
||||
Address = contact.Address;
|
||||
Name = contact.Name;
|
||||
ContactPictureFileId = contact.ContactPictureFileId;
|
||||
Base64ContactPicture = contact.Base64ContactPicture;
|
||||
IsRootContact = contact.IsRootContact;
|
||||
IsOverridden = contact.IsOverridden;
|
||||
}
|
||||
@@ -75,7 +73,6 @@ public partial class AccountContactViewModel : ObservableObject, IMailItemDispla
|
||||
Address = Address,
|
||||
Name = Name,
|
||||
ContactPictureFileId = ContactPictureFileId,
|
||||
Base64ContactPicture = Base64ContactPicture,
|
||||
IsRootContact = IsRootContact,
|
||||
IsOverridden = IsOverridden
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
|
||||
[NotifyPropertyChangedFor(nameof(FileId))]
|
||||
[NotifyPropertyChangedFor(nameof(FolderId))]
|
||||
[NotifyPropertyChangedFor(nameof(UniqueId))]
|
||||
[NotifyPropertyChangedFor(nameof(Base64ContactPicture))]
|
||||
[NotifyPropertyChangedFor(nameof(ContactPictureFileId))]
|
||||
[NotifyPropertyChangedFor(nameof(SenderContact))]
|
||||
public partial MailCopy MailCopy { get; set; } = mailCopy;
|
||||
|
||||
@@ -191,10 +191,14 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
|
||||
set => SetProperty(MailCopy.UniqueId, value, MailCopy, (u, n) => u.UniqueId = n);
|
||||
}
|
||||
|
||||
public string Base64ContactPicture
|
||||
public Guid? ContactPictureFileId
|
||||
{
|
||||
get => MailCopy.SenderContact?.Base64ContactPicture ?? string.Empty;
|
||||
set => SetProperty(MailCopy.SenderContact.Base64ContactPicture, value, MailCopy, (u, n) => u.SenderContact.Base64ContactPicture = n);
|
||||
get => MailCopy.SenderContact?.ContactPictureFileId;
|
||||
set => SetProperty(MailCopy.SenderContact?.ContactPictureFileId, value, MailCopy, (u, n) =>
|
||||
{
|
||||
if (u.SenderContact != null)
|
||||
u.SenderContact.ContactPictureFileId = n;
|
||||
});
|
||||
}
|
||||
|
||||
public DateTime SortingDate => CreationDate;
|
||||
@@ -236,7 +240,7 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
|
||||
nameof(FileId) => MailCopyChangeFlags.FileId,
|
||||
nameof(FolderId) => MailCopyChangeFlags.FolderId,
|
||||
nameof(UniqueId) => MailCopyChangeFlags.UniqueId,
|
||||
nameof(Base64ContactPicture) or nameof(SenderContact) => MailCopyChangeFlags.SenderContact,
|
||||
nameof(ContactPictureFileId) or nameof(SenderContact) => MailCopyChangeFlags.SenderContact,
|
||||
_ => MailCopyChangeFlags.None
|
||||
};
|
||||
}
|
||||
@@ -398,7 +402,7 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
|
||||
|
||||
if ((changedFlags & MailCopyChangeFlags.SenderContact) != 0)
|
||||
{
|
||||
Queue(nameof(Base64ContactPicture));
|
||||
Queue(nameof(ContactPictureFileId));
|
||||
Queue(nameof(SenderContact));
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListIte
|
||||
/// </summary>
|
||||
public Guid UniqueId => latestMailViewModel?.UniqueId ?? Guid.Empty;
|
||||
|
||||
public string Base64ContactPicture => latestMailViewModel?.MailCopy?.SenderContact?.Base64ContactPicture ?? string.Empty;
|
||||
public Guid? ContactPictureFileId => latestMailViewModel?.MailCopy?.SenderContact?.ContactPictureFileId;
|
||||
|
||||
public bool ThumbnailUpdatedEvent => latestMailViewModel?.ThumbnailUpdatedEvent ?? false;
|
||||
|
||||
@@ -188,7 +188,7 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListIte
|
||||
[NotifyPropertyChangedFor(nameof(FileId))]
|
||||
[NotifyPropertyChangedFor(nameof(FolderId))]
|
||||
[NotifyPropertyChangedFor(nameof(UniqueId))]
|
||||
[NotifyPropertyChangedFor(nameof(Base64ContactPicture))]
|
||||
[NotifyPropertyChangedFor(nameof(ContactPictureFileId))]
|
||||
[NotifyPropertyChangedFor(nameof(SenderContact))]
|
||||
public partial ObservableCollection<MailItemViewModel> ThreadEmails { get; set; } = [];
|
||||
|
||||
@@ -369,7 +369,7 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListIte
|
||||
Queue(nameof(FileId));
|
||||
Queue(nameof(FolderId));
|
||||
Queue(nameof(UniqueId));
|
||||
Queue(nameof(Base64ContactPicture));
|
||||
Queue(nameof(ContactPictureFileId));
|
||||
Queue(nameof(SenderContact));
|
||||
Queue(nameof(ThumbnailUpdatedEvent));
|
||||
Queue(nameof(SortingDate));
|
||||
@@ -433,7 +433,7 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListIte
|
||||
|
||||
if ((changedFlags & MailCopyChangeFlags.SenderContact) != 0)
|
||||
{
|
||||
Queue(nameof(Base64ContactPicture));
|
||||
Queue(nameof(ContactPictureFileId));
|
||||
Queue(nameof(SenderContact));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,6 @@ public partial class MailRenderingPageViewModel : MailBaseViewModel,
|
||||
[ObservableProperty]
|
||||
public partial string FromName { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string ContactPicture { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial IMailItemDisplayInformation CurrentMailItemDisplayInformation { get; set; }
|
||||
|
||||
@@ -497,8 +494,6 @@ public partial class MailRenderingPageViewModel : MailBaseViewModel,
|
||||
// Use the received date from MailCopy if available, otherwise fall back to the sent date from MIME message
|
||||
CreationDate = initializedMailItemViewModel?.MailCopy.CreationDate ?? message.Date.DateTime;
|
||||
|
||||
ContactPicture = initializedMailItemViewModel?.MailCopy.SenderContact?.Base64ContactPicture;
|
||||
|
||||
// Automatically disable images for Junk folder to prevent pixel tracking.
|
||||
// This can only work for selected mail item rendering, not for EML file rendering.
|
||||
if (initializedMailItemViewModel != null &&
|
||||
|
||||
Reference in New Issue
Block a user