diff --git a/Directory.Packages.props b/Directory.Packages.props index 01d3266a..dfbf5e6b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -24,9 +24,9 @@ - - - + + + @@ -35,12 +35,12 @@ - + - + @@ -52,21 +52,21 @@ - + - + - + - - + + diff --git a/Wino.Mail.ViewModels/MailListPageViewModel.cs b/Wino.Mail.ViewModels/MailListPageViewModel.cs index add078b1..9e5887a2 100644 --- a/Wino.Mail.ViewModels/MailListPageViewModel.cs +++ b/Wino.Mail.ViewModels/MailListPageViewModel.cs @@ -159,10 +159,14 @@ public partial class MailListPageViewModel : MailBaseViewModel, [NotifyPropertyChangedFor(nameof(IsFolderSynchronizationEnabled))] [NotifyPropertyChangedFor(nameof(IsCategoryView))] [NotifyPropertyChangedFor(nameof(IsSyncButtonVisible))] + [NotifyPropertyChangedFor(nameof(IsJunkFolder))] + [NotifyPropertyChangedFor(nameof(IsEmptyFolderButtonVisible))] + [NotifyCanExecuteChangedFor(nameof(EmptyFolderCommand))] public partial IBaseFolderMenuItem ActiveFolder { get; set; } [ObservableProperty] [NotifyPropertyChangedFor(nameof(CanSynchronize))] + [NotifyCanExecuteChangedFor(nameof(EmptyFolderCommand))] public partial bool IsAccountSynchronizerInSynchronization { get; set; } public MailListPageViewModel(IMailDialogService dialogService, @@ -285,8 +289,10 @@ public partial class MailListPageViewModel : MailBaseViewModel, public bool CanSynchronize => !IsCategoryView && !IsAccountSynchronizerInSynchronization && IsFolderSynchronizationEnabled; public bool IsFolderSynchronizationEnabled => ActiveFolder?.IsSynchronizationEnabled ?? false; public bool IsArchiveSpecialFolder => ActiveFolder?.SpecialFolderType == SpecialFolderType.Archive; + public bool IsJunkFolder => ActiveFolder?.SpecialFolderType == SpecialFolderType.Junk; public bool IsCategoryView => ActiveFolder is IMailCategoryMenuItem or IMergedMailCategoryMenuItem; public bool IsSyncButtonVisible => !IsCategoryView; + public bool IsEmptyFolderButtonVisible => IsJunkFolder; public string SelectedMessageText => IsDragInProgress ? string.Format(Translator.MailsDragging, DraggingItemsCount) @@ -566,6 +572,20 @@ public partial class MailListPageViewModel : MailBaseViewModel, } } + [RelayCommand(CanExecute = nameof(CanEmptyFolder))] + private async Task EmptyFolderAsync() + { + if (!IsJunkFolder || ActiveFolder == null) return; + + foreach (var folder in ActiveFolder.HandlingFolders.OfType()) + { + var folderPrepRequest = new FolderOperationPreperationRequest(FolderOperation.Empty, folder); + await _winoRequestDelegator.ExecuteAsync(folderPrepRequest); + } + } + + private bool CanEmptyFolder() => IsJunkFolder && !IsAccountSynchronizerInSynchronization; + [RelayCommand(CanExecute = nameof(CanLoadMoreItems))] private async Task LoadMoreItemsAsync() { diff --git a/Wino.Mail.WinUI/Views/Mail/MailListPage.xaml b/Wino.Mail.WinUI/Views/Mail/MailListPage.xaml index a506237f..8c42ef3d 100644 --- a/Wino.Mail.WinUI/Views/Mail/MailListPage.xaml +++ b/Wino.Mail.WinUI/Views/Mail/MailListPage.xaml @@ -246,6 +246,14 @@ Grid.Row="1" Grid.Column="2" Orientation="Horizontal"> +