using System; using CommunityToolkit.Mvvm.ComponentModel; using Wino.Core.Domain; using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Interfaces; namespace Wino.Mail.ViewModels.Data; public partial class AccountContactViewModel : ObservableObject, IMailItemDisplayInformation { public AccountContact SourceContact { get; } 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; } public AccountContactViewModel(AccountContact contact) { SourceContact = contact; Address = contact.Address; Name = contact.Name; ContactPictureFileId = contact.ContactPictureFileId; Base64ContactPicture = contact.Base64ContactPicture; IsRootContact = contact.IsRootContact; IsOverridden = contact.IsOverridden; } /// /// Gets or sets whether the contact is the current account. /// public bool IsMe { get; set; } /// /// Gets or sets whether the ShortNameOrYOu should have semicolon. /// public bool IsSemicolon { get; set; } = true; /// /// Provides a short name of the contact. /// or "You" /// public string ShortNameOrYou => (IsMe ? Translator.AccountContactNameYou : ShortDisplayName) + (IsSemicolon ? ";" : string.Empty); /// /// Short display name of the contact. /// Either Name or Address. /// public string ShortDisplayName => Address == Name || string.IsNullOrWhiteSpace(Name) ? $"{Address.ToLowerInvariant()}" : $"{Name}"; /// /// Display name of the contact in a format: Name
. ///
public string DisplayName => Address == Name || string.IsNullOrWhiteSpace(Name) ? Address.ToLowerInvariant() : $"{Name} <{Address.ToLowerInvariant()}>"; [ObservableProperty] public partial bool ThumbnailUpdatedEvent { get; set; } // IMailItemDisplayInformation implementation for avatar-only rendering. public string Subject => string.Empty; public string FromName => Name ?? string.Empty; public string FromAddress => Address ?? string.Empty; public string PreviewText => string.Empty; public bool IsRead => true; public bool IsDraft => false; public bool HasAttachments => false; public bool IsCalendarEvent => false; public bool IsFlagged => false; public DateTime CreationDate => default; public bool IsBusy => false; public bool IsThreadExpanded => false; public AccountContact SenderContact => new() { Address = Address, Name = Name, ContactPictureFileId = ContactPictureFileId, Base64ContactPicture = Base64ContactPicture, IsRootContact = IsRootContact, IsOverridden = IsOverridden }; }