fix(ui): batch UI updates for bulk mark-as-read to prevent UI freeze (#786)

This commit is contained in:
Wynn Zeng
2026-01-28 03:25:05 +08:00
committed by GitHub
parent 7f8c6776fc
commit 4f65502c95
5 changed files with 73 additions and 9 deletions
@@ -596,13 +596,22 @@ public partial class MailRenderingPageViewModel : MailBaseViewModel,
// This is done with UniqueId to include FolderId into calculations.
if (initializedMailItemViewModel.UniqueId != updatedMail.UniqueId) return;
// Mail operation might change the mail item like mark read/unread or change flag.
// So we need to update the mail item view model when this happens.
// Also command bar items must be re-initialized since the items loaded based on the mail item.
await ExecuteUIThread(() => { InitializeCommandBarItems(); });
}
protected override async void OnMailUpdated(IReadOnlyList<MailCopy> updatedMails)
{
base.OnMailUpdated(updatedMails);
if (initializedMailItemViewModel == null || updatedMails == null || updatedMails.Count == 0) return;
// Only care about the currently rendered item.
if (updatedMails.Any(m => m?.UniqueId == initializedMailItemViewModel.UniqueId))
{
await ExecuteUIThread(() => { InitializeCommandBarItems(); });
}
}
[RelayCommand]
private async Task OpenAttachmentAsync(MailAttachmentViewModel attachmentViewModel)
{