Some experiments.

This commit is contained in:
Burak Kaan Köse
2026-01-27 20:37:18 +01:00
parent 31097e42a9
commit b343152f14
7 changed files with 123 additions and 11 deletions
@@ -184,4 +184,67 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
yield return this;
}
}
/// <summary>
/// Updates the MailCopy with new data and notifies all bound properties.
/// This method copies values from the source to the existing MailCopy to maintain reference integrity,
/// then explicitly raises PropertyChanged for all dependent properties.
/// </summary>
/// <param name="source">The source MailCopy with updated values.</param>
public void UpdateFrom(MailCopy source)
{
if (source == null) return;
// Update the underlying MailCopy properties directly to maintain reference integrity
// This is important because other parts of the app may hold references to this MailCopy
// Note: UniqueId is the primary key and should match - we don't update it
MailCopy.Id = source.Id;
MailCopy.FolderId = source.FolderId;
MailCopy.ThreadId = source.ThreadId;
MailCopy.MessageId = source.MessageId;
MailCopy.References = source.References;
MailCopy.InReplyTo = source.InReplyTo;
MailCopy.IsDraft = source.IsDraft;
MailCopy.DraftId = source.DraftId;
MailCopy.CreationDate = source.CreationDate;
MailCopy.Subject = source.Subject;
MailCopy.PreviewText = source.PreviewText;
MailCopy.FromName = source.FromName;
MailCopy.FromAddress = source.FromAddress;
MailCopy.HasAttachments = source.HasAttachments;
MailCopy.Importance = source.Importance;
MailCopy.IsRead = source.IsRead;
MailCopy.IsFlagged = source.IsFlagged;
MailCopy.IsFocused = source.IsFocused;
MailCopy.FileId = source.FileId;
MailCopy.ItemType = source.ItemType;
MailCopy.SenderContact = source.SenderContact;
MailCopy.AssignedAccount = source.AssignedAccount;
MailCopy.AssignedFolder = source.AssignedFolder;
// Raise PropertyChanged for all properties that XAML may bind to
OnPropertyChanged(nameof(CreationDate));
OnPropertyChanged(nameof(IsFlagged));
OnPropertyChanged(nameof(FromName));
OnPropertyChanged(nameof(IsFocused));
OnPropertyChanged(nameof(IsRead));
OnPropertyChanged(nameof(IsDraft));
OnPropertyChanged(nameof(DraftId));
OnPropertyChanged(nameof(Id));
OnPropertyChanged(nameof(Subject));
OnPropertyChanged(nameof(PreviewText));
OnPropertyChanged(nameof(FromAddress));
OnPropertyChanged(nameof(HasAttachments));
OnPropertyChanged(nameof(Importance));
OnPropertyChanged(nameof(ThreadId));
OnPropertyChanged(nameof(MessageId));
OnPropertyChanged(nameof(References));
OnPropertyChanged(nameof(InReplyTo));
OnPropertyChanged(nameof(FileId));
OnPropertyChanged(nameof(FolderId));
OnPropertyChanged(nameof(UniqueId));
OnPropertyChanged(nameof(Base64ContactPicture));
OnPropertyChanged(nameof(SortingDate));
OnPropertyChanged(nameof(SortingName));
}
}
@@ -213,6 +213,40 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListIte
}
}
/// <summary>
/// Notifies that a mail item within this thread has been updated.
/// This raises PropertyChanged for all thread-level computed properties that depend on child items.
/// </summary>
/// <param name="updatedMailItem">The mail item that was updated (can be null to refresh all).</param>
public void NotifyMailItemUpdated(MailItemViewModel updatedMailItem)
{
// Raise PropertyChanged for all computed properties that depend on ThreadEmails contents
OnPropertyChanged(nameof(Subject));
OnPropertyChanged(nameof(FromName));
OnPropertyChanged(nameof(CreationDate));
OnPropertyChanged(nameof(FromAddress));
OnPropertyChanged(nameof(PreviewText));
OnPropertyChanged(nameof(HasAttachments));
OnPropertyChanged(nameof(IsFlagged));
OnPropertyChanged(nameof(IsFocused));
OnPropertyChanged(nameof(IsRead));
OnPropertyChanged(nameof(IsDraft));
OnPropertyChanged(nameof(DraftId));
OnPropertyChanged(nameof(Id));
OnPropertyChanged(nameof(Importance));
OnPropertyChanged(nameof(ThreadId));
OnPropertyChanged(nameof(MessageId));
OnPropertyChanged(nameof(References));
OnPropertyChanged(nameof(InReplyTo));
OnPropertyChanged(nameof(FileId));
OnPropertyChanged(nameof(FolderId));
OnPropertyChanged(nameof(UniqueId));
OnPropertyChanged(nameof(Base64ContactPicture));
OnPropertyChanged(nameof(ThumbnailUpdatedEvent));
OnPropertyChanged(nameof(SortingDate));
OnPropertyChanged(nameof(SortingName));
}
/// <summary>
/// Checks if this thread contains an email with the specified unique ID
/// </summary>