diff --git a/OF DL.Gui/ViewModels/MainWindowViewModel.cs b/OF DL.Gui/ViewModels/MainWindowViewModel.cs index 2b80064..a00da50 100644 --- a/OF DL.Gui/ViewModels/MainWindowViewModel.cs +++ b/OF DL.Gui/ViewModels/MainWindowViewModel.cs @@ -354,6 +354,15 @@ public partial class MainWindowViewModel( [ObservableProperty] private string _missingCdmWarningMessage = string.Empty; + [ObservableProperty] + [NotifyCanExecuteChangedFor(nameof(OpenSinglePostOrMessageModalCommand))] + [NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))] + [NotifyCanExecuteChangedFor(nameof(DownloadSelectedCommand))] + [NotifyCanExecuteChangedFor(nameof(DownloadPurchasedTabCommand))] + private bool _isDownloadSelectionWarningModalOpen; + + [ObservableProperty] private string _downloadSelectionWarningMessage = string.Empty; + [ObservableProperty] [NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))] private string _singlePostOrMessageUrl = string.Empty; @@ -485,6 +494,7 @@ public partial class MainWindowViewModel( private bool _isUpdatingAllUsersSelected; private TaskCompletionSource? _missingCdmWarningCompletionSource; + private TaskCompletionSource? _downloadSelectionWarningCompletionSource; public async Task InitializeAsync() { @@ -880,6 +890,28 @@ public partial class MainWindowViewModel( _missingCdmWarningCompletionSource?.TrySetResult(false); } + [RelayCommand] + private void ConfirmDownloadSelectionWarning() + { + IsDownloadSelectionWarningModalOpen = false; + _downloadSelectionWarningCompletionSource?.TrySetResult(true); + } + + [RelayCommand] + private void CancelDownloadSelectionWarning() + { + IsDownloadSelectionWarningModalOpen = false; + _downloadSelectionWarningCompletionSource?.TrySetResult(false); + } + + [RelayCommand] + private void OpenConfigurationFromDownloadSelectionWarning() + { + IsDownloadSelectionWarningModalOpen = false; + _downloadSelectionWarningCompletionSource?.TrySetResult(false); + EditConfig(); + } + [RelayCommand(CanExecute = nameof(CanStopWork))] private void StopWork() { @@ -904,6 +936,11 @@ public partial class MainWindowViewModel( return; } + if (!await EnsureDownloadSelectionWarningConfirmedAsync()) + { + return; + } + if (!await EnsureMissingCdmWarningConfirmedAsync()) { return; @@ -993,23 +1030,27 @@ public partial class MainWindowViewModel( private bool CanDownloadSelected() => CurrentScreen == AppScreen.UserSelection && AvailableUsers.Any(user => user.IsSelected) && + !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && !IsDownloading; private bool CanDownloadPurchasedTab() => CurrentScreen == AppScreen.UserSelection && _allUsers.Count > 0 && + !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && !IsDownloading; private bool CanOpenSinglePostOrMessageModal() => CurrentScreen == AppScreen.UserSelection && !IsDownloading && + !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && !IsSinglePostOrMessageModalOpen; private bool CanSubmitSinglePostOrMessage() => IsSinglePostOrMessageModalOpen && + !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && !IsDownloading && !string.IsNullOrWhiteSpace(SinglePostOrMessageUrl); @@ -1337,6 +1378,47 @@ public partial class MainWindowViewModel( return confirmed; } + private async Task EnsureDownloadSelectionWarningConfirmedAsync() + { + bool hasEnabledMediaType = configService.CurrentConfig.DownloadVideos || + configService.CurrentConfig.DownloadImages || + configService.CurrentConfig.DownloadAudios; + bool hasEnabledSource = configService.CurrentConfig.DownloadPosts || + configService.CurrentConfig.DownloadPaidPosts || + configService.CurrentConfig.DownloadMessages || + configService.CurrentConfig.DownloadPaidMessages || + configService.CurrentConfig.DownloadArchived || + configService.CurrentConfig.DownloadStreams || + configService.CurrentConfig.DownloadStories || + configService.CurrentConfig.DownloadHighlights || + configService.CurrentConfig.DownloadAvatarHeaderPhoto; + if (hasEnabledMediaType && hasEnabledSource) + { + return true; + } + + DownloadSelectionWarningMessage = + "No files will be downloaded unless at least one media type and at least one source are enabled in \"Download Media Types\" on the Configuration page.\n\n" + + "Without enabling these options, only metadata will be saved."; + + _downloadSelectionWarningCompletionSource = + new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + IsDownloadSelectionWarningModalOpen = true; + + bool confirmed; + try + { + confirmed = await _downloadSelectionWarningCompletionSource.Task; + } + finally + { + _downloadSelectionWarningCompletionSource = null; + IsDownloadSelectionWarningModalOpen = false; + } + + return confirmed; + } + private static bool TryParseSinglePostOrMessageUrl( string url, out SingleDownloadRequest request, @@ -2187,18 +2269,18 @@ public partial class MainWindowViewModel( nameof(Config.FFmpegPath) => "External", nameof(Config.FFprobePath) => "External", - nameof(Config.DownloadAvatarHeaderPhoto) => "Download Media Types", - nameof(Config.DownloadPaidPosts) => "Download Media Types", - nameof(Config.DownloadPosts) => "Download Media Types", - nameof(Config.DownloadArchived) => "Download Media Types", - nameof(Config.DownloadStreams) => "Download Media Types", - nameof(Config.DownloadStories) => "Download Media Types", - nameof(Config.DownloadHighlights) => "Download Media Types", - nameof(Config.DownloadMessages) => "Download Media Types", - nameof(Config.DownloadPaidMessages) => "Download Media Types", - nameof(Config.DownloadImages) => "Download Media Types", - nameof(Config.DownloadVideos) => "Download Media Types", - nameof(Config.DownloadAudios) => "Download Media Types", + nameof(Config.DownloadAvatarHeaderPhoto) => "Download Media Types and Sources", + nameof(Config.DownloadPaidPosts) => "Download Media Types and Sources", + nameof(Config.DownloadPosts) => "Download Media Types and Sources", + nameof(Config.DownloadArchived) => "Download Media Types and Sources", + nameof(Config.DownloadStreams) => "Download Media Types and Sources", + nameof(Config.DownloadStories) => "Download Media Types and Sources", + nameof(Config.DownloadHighlights) => "Download Media Types and Sources", + nameof(Config.DownloadMessages) => "Download Media Types and Sources", + nameof(Config.DownloadPaidMessages) => "Download Media Types and Sources", + nameof(Config.DownloadImages) => "Download Media Types and Sources", + nameof(Config.DownloadVideos) => "Download Media Types and Sources", + nameof(Config.DownloadAudios) => "Download Media Types and Sources", nameof(Config.IgnoreOwnMessages) => "Download Behavior", nameof(Config.DownloadPostsIncrementally) => "Download Behavior", @@ -2246,7 +2328,7 @@ public partial class MainWindowViewModel( { "Auth" => 0, "External" => 1, - "Download Media Types" => 2, + "Download Media Types and Sources" => 2, "Download Behavior" => 3, "File Naming" => 4, "Folder Structure" => 5, diff --git a/OF DL.Gui/Views/MainWindow.axaml b/OF DL.Gui/Views/MainWindow.axaml index b13b8b9..a12db02 100644 --- a/OF DL.Gui/Views/MainWindow.axaml +++ b/OF DL.Gui/Views/MainWindow.axaml @@ -254,7 +254,7 @@ + Text="Download Media Types and Sources" /> + + + + + + + +