98eed39fe6
Introduce a dedicated settings page that lets users reorder, hide, and pin/unpin folders per account. Folders are organized into Pinned, Categories (Gmail only), and More sections with drag-to-reorder via ListView. New Order column on MailItemFolder persists the custom layout; the default sort falls back to alphabetic when no custom order is set. A reset action wipes all customization in a single transaction and restores system-folder stickiness. Co-authored-by: Claude <noreply@anthropic.com>
82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using SQLite;
|
|
using Wino.Core.Domain.Enums;
|
|
using Wino.Core.Domain.Models.Folders;
|
|
|
|
namespace Wino.Core.Domain.Entities.Mail;
|
|
|
|
[DebuggerDisplay("{FolderName} - {SpecialFolderType}")]
|
|
public class MailItemFolder : IMailItemFolder
|
|
{
|
|
[PrimaryKey]
|
|
public Guid Id { get; set; }
|
|
|
|
public string RemoteFolderId { get; set; }
|
|
public string ParentRemoteFolderId { get; set; }
|
|
|
|
public Guid MailAccountId { get; set; }
|
|
public string FolderName { get; set; }
|
|
public SpecialFolderType SpecialFolderType { get; set; }
|
|
public bool IsSystemFolder { get; set; }
|
|
public bool IsSticky { get; set; }
|
|
public bool IsSynchronizationEnabled { get; set; }
|
|
public bool IsHidden { get; set; }
|
|
public bool ShowUnreadCount { get; set; }
|
|
|
|
// User-defined ordering within its navigation section (Pinned / Categories / More).
|
|
// 0 means "no custom order set" — the folder falls back to the default sort
|
|
// (alphabetic for More, canonical SpecialFolderType order as a tiebreak for Pinned).
|
|
public int Order { get; set; }
|
|
public DateTime? LastSynchronizedDate { get; set; }
|
|
|
|
// For IMAP
|
|
public uint UidValidity { get; set; }
|
|
public long HighestModeSeq { get; set; }
|
|
public uint HighestKnownUid { get; set; }
|
|
public DateTime? LastUidReconcileUtc { get; set; }
|
|
|
|
/// <summary>
|
|
/// Outlook shares delta changes per-folder. Gmail is for per-account.
|
|
/// This is only used for Outlook provider.
|
|
/// </summary>
|
|
public string DeltaToken { get; set; }
|
|
|
|
// For GMail Labels
|
|
public string TextColorHex { get; set; }
|
|
public string BackgroundColorHex { get; set; }
|
|
|
|
[Ignore]
|
|
public List<IMailItemFolder> ChildFolders { get; set; } = [];
|
|
|
|
// Category and Move type folders are not valid move targets.
|
|
// These folders are virtual. They don't exist on the server.
|
|
public bool IsMoveTarget => !(SpecialFolderType == SpecialFolderType.More || SpecialFolderType == SpecialFolderType.Category);
|
|
|
|
public bool ContainsSpecialFolderType(SpecialFolderType type)
|
|
{
|
|
if (SpecialFolderType == type)
|
|
return true;
|
|
|
|
foreach (var child in ChildFolders)
|
|
{
|
|
if (child.SpecialFolderType == type)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return child.ContainsSpecialFolderType(type);
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static MailItemFolder CreateMoreFolder() => new MailItemFolder() { IsSticky = true, SpecialFolderType = SpecialFolderType.More, FolderName = Translator.MoreFolderNameOverride };
|
|
public static MailItemFolder CreateCategoriesFolder() => new MailItemFolder() { IsSticky = true, SpecialFolderType = SpecialFolderType.Category, FolderName = Translator.CategoriesFolderNameOverride };
|
|
|
|
public override string ToString() => FolderName;
|
|
}
|