Files
Wino-Mail/Wino.Core/MenuItems/FolderMenuItem.cs
Burak Kaan Köse 536fbb23a1 Folder operations, Gmail folder sync improvements and rework of menu items. (#273)
* New rename folder dialog keys.

* Insfra work for folder operations and rename folder code.

* RenameFolder for Gmail.

* Fixed input dialog to take custom take for primary button.

* Missing rename for DS call.

* Outlook to throw exception in case of error.

* Implemented rename folder functionality for Outlook.

* Remove default primary text from input dialog.

* Fixed an issue where outlook folder rename does not work.

* Disable vertical scroll for composing page editor items.

* Fixing some issues with imap folder sync.

* fix copy pasta

* TODO folder update/removed overrides for shell.

* New rename folder dialog keys.

* Insfra work for folder operations and rename folder code.

* RenameFolder for Gmail.

* Fixed input dialog to take custom take for primary button.

* Missing rename for DS call.

* Outlook to throw exception in case of error.

* Implemented rename folder functionality for Outlook.

* Remove default primary text from input dialog.

* Fixed an issue where outlook folder rename does not work.

* Disable vertical scroll for composing page editor items.

* Fixing some issues with imap folder sync.

* fix copy pasta

* TODO folder update/removed overrides for shell.

* New rename folder dialog keys.

* Insfra work for folder operations and rename folder code.

* RenameFolder for Gmail.

* Fixed input dialog to take custom take for primary button.

* Missing rename for DS call.

* Outlook to throw exception in case of error.

* Implemented rename folder functionality for Outlook.

* Remove default primary text from input dialog.

* Fixed an issue where outlook folder rename does not work.

* Disable vertical scroll for composing page editor items.

* Fixing some issues with imap folder sync.

* fix copy pasta

* TODO folder update/removed overrides for shell.

* New rename folder dialog keys.

* Fixed an issue where redundant older updates causing pivots to be re-created.

* New empty folder request

* New rename folder dialog keys.

* Insfra work for folder operations and rename folder code.

* RenameFolder for Gmail.

* Fixed input dialog to take custom take for primary button.

* Missing rename for DS call.

* Outlook to throw exception in case of error.

* Implemented rename folder functionality for Outlook.

* Remove default primary text from input dialog.

* Fixed an issue where outlook folder rename does not work.

* Fixing some issues with imap folder sync.

* fix copy pasta

* TODO folder update/removed overrides for shell.

* New rename folder dialog keys.

* New rename folder dialog keys.

* New rename folder dialog keys.

* Fixed an issue where redundant older updates causing pivots to be re-created.

* New empty folder request

* Enable empty folder on base sync.

* Move updates on event listeners.

* Remove folder UI messages.

* Reworked folder synchronization for gmail.

* Loading folders on the fly as the selected account changed instead of relying on cached menu items.

* Merged account folder items, re-navigating to existing rendering page.

* - Reworked merged account menu system.
- Reworked unread item count loadings.
- Fixed back button visibility.
- Instant rendering of mails if renderer is active.
- Animation fixes.
- Menu item re-load crash/hang fixes.

* Handle folder renaming on the UI.

* Empty folder for all synchronizers.

* New execution delay mechanism and handling folder mark as read for all synchronizers.

* Revert UI changes on failure for IMAP.

* Remove duplicate translation keys.

* Cleanup.
2024-07-09 01:05:16 +02:00

80 lines
3.0 KiB
C#

using System.Collections.Generic;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Folders;
namespace Wino.Core.MenuItems
{
public partial class FolderMenuItem : MenuItemBase<IMailItemFolder, FolderMenuItem>, IFolderMenuItem
{
[ObservableProperty]
private int unreadItemCount;
public bool HasTextColor => !string.IsNullOrEmpty(Parameter.TextColorHex);
public bool IsMoveTarget => HandlingFolders.All(a => a.IsMoveTarget);
public SpecialFolderType SpecialFolderType => Parameter.SpecialFolderType;
public bool IsSticky => Parameter.IsSticky;
public bool IsSystemFolder => Parameter.IsSystemFolder;
/// <summary>
/// Display name of the folder. More and Category folders have localized display names.
/// </summary>
public string FolderName
{
get
{
if (Parameter.SpecialFolderType == SpecialFolderType.More)
return Translator.MoreFolderNameOverride;
else if (Parameter.SpecialFolderType == SpecialFolderType.Category)
return Translator.CategoriesFolderNameOverride;
else
return Parameter.FolderName;
}
set => SetProperty(Parameter.FolderName, value, Parameter, (u, n) => u.FolderName = n);
}
public bool IsSynchronizationEnabled
{
get => Parameter.IsSynchronizationEnabled;
set => SetProperty(Parameter.IsSynchronizationEnabled, value, Parameter, (u, n) => u.IsSynchronizationEnabled = n);
}
public IEnumerable<IMailItemFolder> HandlingFolders => new List<IMailItemFolder>() { Parameter };
public MailAccount ParentAccount { get; private set; }
public string AssignedAccountName => ParentAccount?.Name;
public bool ShowUnreadCount => Parameter.ShowUnreadCount;
IEnumerable<IMenuItem> IBaseFolderMenuItem.SubMenuItems => SubMenuItems;
public FolderMenuItem(IMailItemFolder folderStructure, MailAccount parentAccount, IMenuItem parentMenuItem) : base(folderStructure, folderStructure.Id, parentMenuItem)
{
ParentAccount = parentAccount;
}
public void UpdateFolder(IMailItemFolder folder)
{
Parameter = folder;
OnPropertyChanged(nameof(IsSynchronizationEnabled));
OnPropertyChanged(nameof(ShowUnreadCount));
OnPropertyChanged(nameof(HasTextColor));
OnPropertyChanged(nameof(IsSystemFolder));
OnPropertyChanged(nameof(SpecialFolderType));
OnPropertyChanged(nameof(IsSticky));
OnPropertyChanged(nameof(FolderName));
}
public override string ToString() => FolderName;
public void UpdateParentAccounnt(MailAccount account) => ParentAccount = account;
}
}