Bunch of improvements i dunno.
This commit is contained in:
@@ -14,18 +14,57 @@ public partial class AccountMenuItem : MenuItemBase<MailAccount, MenuItemBase<IM
|
||||
[ObservableProperty]
|
||||
private int unreadItemCount;
|
||||
|
||||
/// <summary>
|
||||
/// Total items to sync. 0 means indeterminate progress.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(IsSynchronizationProgressVisible))]
|
||||
private double synchronizationProgress;
|
||||
[NotifyPropertyChangedFor(nameof(IsSynchronizationProgressVisible), nameof(SynchronizationProgress), nameof(IsProgressIndeterminate))]
|
||||
public partial int TotalItemsToSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remaining items to sync.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(SynchronizationProgress))]
|
||||
public partial int RemainingItemsToSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current synchronization status message.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public partial string SynchronizationStatus { get; set; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isEnabled = true;
|
||||
|
||||
public bool IsAttentionRequired => AttentionReason != AccountAttentionReason.None;
|
||||
public bool IsSynchronizationProgressVisible => SynchronizationProgress > 0 && SynchronizationProgress < 100;
|
||||
|
||||
// We can't determine the progress for gmail synchronization since it is based on history changes.
|
||||
public bool IsProgressIndeterminate => Parameter?.ProviderType == MailProviderType.Gmail;
|
||||
/// <summary>
|
||||
/// Calculates synchronization progress percentage (0-100).
|
||||
/// Returns -1 for indeterminate progress when TotalItemsToSync is 0.
|
||||
/// </summary>
|
||||
public double SynchronizationProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TotalItemsToSync == 0 || RemainingItemsToSync == 0)
|
||||
return -1; // Indeterminate
|
||||
|
||||
return ((double)(TotalItemsToSync - RemainingItemsToSync) / TotalItemsToSync) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether synchronization progress should be visible.
|
||||
/// Visible when there's active synchronization (TotalItemsToSync > 0 or RemainingItemsToSync > 0).
|
||||
/// </summary>
|
||||
public bool IsSynchronizationProgressVisible => TotalItemsToSync > 0 || RemainingItemsToSync > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Whether progress should be indeterminate (when total is 0 but there's still synchronization happening).
|
||||
/// </summary>
|
||||
public bool IsProgressIndeterminate => TotalItemsToSync == 0 && RemainingItemsToSync == 0 && IsSynchronizationProgressVisible;
|
||||
|
||||
public Guid AccountId => Parameter.Id;
|
||||
|
||||
private AccountAttentionReason attentionReason;
|
||||
|
||||
@@ -16,8 +16,39 @@ public partial class MergedAccountMenuItem : MenuItemBase<MergedInbox, IMenuItem
|
||||
[ObservableProperty]
|
||||
private int unreadItemCount;
|
||||
|
||||
/// <summary>
|
||||
/// Total items to sync across all merged accounts.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double synchronizationProgress;
|
||||
[NotifyPropertyChangedFor(nameof(SynchronizationProgress))]
|
||||
public partial int TotalItemsToSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remaining items to sync across all merged accounts.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(SynchronizationProgress))]
|
||||
public partial int RemainingItemsToSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current synchronization status message.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public partial string SynchronizationStatus { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Calculated synchronization progress for merged accounts.
|
||||
/// </summary>
|
||||
public double SynchronizationProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TotalItemsToSync == 0 || RemainingItemsToSync == 0)
|
||||
return -1; // Indeterminate
|
||||
|
||||
return ((double)(TotalItemsToSync - RemainingItemsToSync) / TotalItemsToSync) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private string mergedAccountName;
|
||||
@@ -35,6 +66,20 @@ public partial class MergedAccountMenuItem : MenuItemBase<MergedInbox, IMenuItem
|
||||
{
|
||||
UnreadItemCount = SubMenuItems.OfType<IAccountMenuItem>().Sum(a => a.UnreadItemCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggregates synchronization progress from all child account menu items.
|
||||
/// </summary>
|
||||
public void RefreshSynchronizationProgress()
|
||||
{
|
||||
var accountMenuItems = SubMenuItems.OfType<IAccountMenuItem>().ToList();
|
||||
|
||||
TotalItemsToSync = accountMenuItems.Sum(a => a.TotalItemsToSync);
|
||||
RemainingItemsToSync = accountMenuItems.Sum(a => a.RemainingItemsToSync);
|
||||
|
||||
// Use first non-empty status message
|
||||
SynchronizationStatus = accountMenuItems.FirstOrDefault(a => !string.IsNullOrEmpty(a.SynchronizationStatus))?.SynchronizationStatus ?? string.Empty;
|
||||
}
|
||||
|
||||
public void UpdateAccount(MailAccount account)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user