diff --git a/Lantean.QBTMud/Components/Dialogs/AddTorrentOptions.razor.cs b/Lantean.QBTMud/Components/Dialogs/AddTorrentOptions.razor.cs index fa298b2..9e51e2a 100644 --- a/Lantean.QBTMud/Components/Dialogs/AddTorrentOptions.razor.cs +++ b/Lantean.QBTMud/Components/Dialogs/AddTorrentOptions.razor.cs @@ -53,7 +53,7 @@ namespace Lantean.QBTMud.Components.Dialogs TorrentManagementMode = preferences.AutoTmmEnabled; SavePath = preferences.SavePath; - StartTorrent = !preferences.StartPausedEnabled; + StartTorrent = !preferences.AddStoppedEnabled; AddToTopOfQueue = preferences.AddToTopOfQueue; StopCondition = preferences.TorrentStopCondition; ContentLayout = preferences.TorrentContentLayout; @@ -78,4 +78,4 @@ namespace Lantean.QBTMud.Components.Dialogs UploadLimit); } } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Components/FiltersNav.razor b/Lantean.QBTMud/Components/FiltersNav.razor index cdc289a..3912c6e 100644 --- a/Lantean.QBTMud/Components/FiltersNav.razor +++ b/Lantean.QBTMud/Components/FiltersNav.razor @@ -65,8 +65,8 @@ { return __builder => { - Resume torrents - Pause torrents + Start torrents + Stop torrents Remove torrents }; } diff --git a/Lantean.QBTMud/Components/FiltersNav.razor.cs b/Lantean.QBTMud/Components/FiltersNav.razor.cs index b8a7941..bcd796f 100644 --- a/Lantean.QBTMud/Components/FiltersNav.razor.cs +++ b/Lantean.QBTMud/Components/FiltersNav.razor.cs @@ -5,6 +5,7 @@ using Lantean.QBTMud.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using MudBlazor; +using System.Linq; namespace Lantean.QBTMud.Components { @@ -352,18 +353,18 @@ namespace Lantean.QBTMud.Components } } - protected async Task ResumeTorrents(string type) + protected async Task StartTorrents(string type) { var torrents = GetAffectedTorrentHashes(type); - await ApiClient.ResumeTorrents(torrents); + await ApiClient.StartTorrents(hashes: torrents.ToArray()); } - protected async Task PauseTorrents(string type) + protected async Task StopTorrents(string type) { var torrents = GetAffectedTorrentHashes(type); - await ApiClient.PauseTorrents(torrents); + await ApiClient.StopTorrents(hashes: torrents.ToArray()); } protected async Task RemoveTorrents(string type) @@ -477,4 +478,4 @@ namespace Lantean.QBTMud.Components } } } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Components/Options/DownloadsOptions.razor b/Lantean.QBTMud/Components/Options/DownloadsOptions.razor index 044d18c..503a2dd 100644 --- a/Lantean.QBTMud/Components/Options/DownloadsOptions.razor +++ b/Lantean.QBTMud/Components/Options/DownloadsOptions.razor @@ -19,7 +19,7 @@ - + @@ -306,4 +306,4 @@ - \ No newline at end of file + diff --git a/Lantean.QBTMud/Components/Options/DownloadsOptions.razor.cs b/Lantean.QBTMud/Components/Options/DownloadsOptions.razor.cs index c7169ce..eec1c34 100644 --- a/Lantean.QBTMud/Components/Options/DownloadsOptions.razor.cs +++ b/Lantean.QBTMud/Components/Options/DownloadsOptions.razor.cs @@ -6,7 +6,7 @@ namespace Lantean.QBTMud.Components.Options { protected string? TorrentContentLayout { get; set; } protected bool AddToTopOfQueue { get; set; } - protected bool StartPausedEnabled { get; set; } + protected bool AddStoppedEnabled { get; set; } protected string? TorrentStopCondition { get; set; } protected bool AutoDeleteMode { get; set; } protected bool PreallocateAll { get; set; } @@ -51,7 +51,7 @@ namespace Lantean.QBTMud.Components.Options // when adding a torrent TorrentContentLayout = Preferences.TorrentContentLayout; AddToTopOfQueue = Preferences.AddToTopOfQueue; - StartPausedEnabled = Preferences.StartPausedEnabled; + AddStoppedEnabled = Preferences.AddStoppedEnabled; TorrentStopCondition = Preferences.TorrentStopCondition; AutoDeleteMode = Preferences.AutoDeleteMode == 1; PreallocateAll = Preferences.PreallocateAll; @@ -116,10 +116,10 @@ namespace Lantean.QBTMud.Components.Options await PreferencesChanged.InvokeAsync(UpdatePreferences); } - protected async Task StartPausedEnabledChanged(bool value) + protected async Task AddStoppedEnabledChanged(bool value) { - StartPausedEnabled = value; - UpdatePreferences.StartPausedEnabled = value; + AddStoppedEnabled = value; + UpdatePreferences.AddStoppedEnabled = value; await PreferencesChanged.InvokeAsync(UpdatePreferences); } @@ -410,4 +410,4 @@ namespace Lantean.QBTMud.Components.Options return null; } } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Components/TorrentActions.razor.cs b/Lantean.QBTMud/Components/TorrentActions.razor.cs index e0d24a5..9ceeeaf 100644 --- a/Lantean.QBTMud/Components/TorrentActions.razor.cs +++ b/Lantean.QBTMud/Components/TorrentActions.razor.cs @@ -7,6 +7,7 @@ using Lantean.QBTMud.Services; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MudBlazor; +using System.Linq; namespace Lantean.QBTMud.Components { @@ -77,8 +78,8 @@ namespace Lantean.QBTMud.Components { _actions = [ - new("start", "Start", Icons.Material.Filled.PlayArrow, Color.Success, CreateCallback(Resume)), - new("pause", "Pause", MajorVersion < 5 ? Icons.Material.Filled.Pause : Icons.Material.Filled.Stop, Color.Warning, CreateCallback(Pause)), + new("start", "Start", Icons.Material.Filled.PlayArrow, Color.Success, CreateCallback(Start)), + new("stop", "Stop", Icons.Material.Filled.Stop, Color.Warning, CreateCallback(Stop)), new("forceStart", "Force start", Icons.Material.Filled.Forward, Color.Warning, CreateCallback(ForceStart)), new("delete", "Remove", Icons.Material.Filled.Delete, Color.Error, CreateCallback(Remove), separatorBefore: true), new("setLocation", "Set location", Icons.Material.Filled.MyLocation, Color.Info, CreateCallback(SetLocation), separatorBefore: true), @@ -146,32 +147,16 @@ namespace Lantean.QBTMud.Components OverlayVisible = value; } - protected async Task Pause() + protected async Task Stop() { - if (MajorVersion < 5) - { - await ApiClient.PauseTorrents(Hashes); - Snackbar.Add("Torrent paused."); - } - else - { - await ApiClient.StopTorrents(Hashes); - Snackbar.Add("Torrent stopped."); - } + await ApiClient.StopTorrents(hashes: Hashes.ToArray()); + Snackbar.Add(MajorVersion < 5 ? "Torrent paused." : "Torrent stopped."); } - protected async Task Resume() + protected async Task Start() { - if (MajorVersion < 5) - { - await ApiClient.ResumeTorrents(Hashes); - Snackbar.Add("Torrent resumed."); - } - else - { - await ApiClient.StartTorrents(Hashes); - Snackbar.Add("Torrent started."); - } + await ApiClient.StartTorrents(hashes: Hashes.ToArray()); + Snackbar.Add(MajorVersion < 5 ? "Torrent resumed." : "Torrent started."); } protected async Task ForceStart() @@ -706,4 +691,4 @@ namespace Lantean.QBTMud.Components MenuItems, } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Components/TrackersTab.razor.cs b/Lantean.QBTMud/Components/TrackersTab.razor.cs index 2697924..d703fe0 100644 --- a/Lantean.QBTMud/Components/TrackersTab.razor.cs +++ b/Lantean.QBTMud/Components/TrackersTab.razor.cs @@ -171,7 +171,7 @@ namespace Lantean.QBTMud.Components return; } - await ApiClient.AddTrackersToTorrent(Hash, trackers); + await ApiClient.AddTrackersToTorrent(trackers, hashes: new[] { Hash }); } protected Task EditTrackerToolbar() @@ -211,7 +211,7 @@ namespace Lantean.QBTMud.Components return; } - await ApiClient.RemoveTrackers(Hash, [tracker.Url]); + await ApiClient.RemoveTrackers([tracker.Url], hashes: new[] { Hash }); } protected Task CopyTrackerUrlToolbar() @@ -303,4 +303,4 @@ namespace Lantean.QBTMud.Components GC.SuppressFinalize(this); } } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Helpers/DialogHelper.cs b/Lantean.QBTMud/Helpers/DialogHelper.cs index 50f843e..e3b7282 100644 --- a/Lantean.QBTMud/Helpers/DialogHelper.cs +++ b/Lantean.QBTMud/Helpers/DialogHelper.cs @@ -3,6 +3,7 @@ using Lantean.QBTMud.Components.Dialogs; using Lantean.QBTMud.Filter; using Lantean.QBTMud.Models; using MudBlazor; +using System.Linq; namespace Lantean.QBTMud.Helpers { @@ -56,7 +57,7 @@ namespace Lantean.QBTMud.Helpers var addTorrentParams = CreateAddTorrentParams(options); addTorrentParams.Torrents = files; - await apiClient.AddTorrent(addTorrentParams); + _ = await apiClient.AddTorrent(addTorrentParams); foreach (var stream in streams) { @@ -74,15 +75,10 @@ namespace Lantean.QBTMud.Helpers { addTorrentParams.ContentLayout = Enum.Parse(options.ContentLayout); } - if (string.IsNullOrEmpty(options.Cookie)) - { - addTorrentParams.Cookie = options.Cookie; - } addTorrentParams.DownloadLimit = options.DownloadLimit; addTorrentParams.DownloadPath = options.DownloadPath; addTorrentParams.FirstLastPiecePriority = options.DownloadFirstAndLastPiecesFirst; addTorrentParams.InactiveSeedingTimeLimit = options.InactiveSeedingTimeLimit; - addTorrentParams.Paused = !options.StartTorrent; addTorrentParams.RatioLimit = options.RatioLimit; addTorrentParams.RenameTorrent = options.RenameTorrent; addTorrentParams.SavePath = options.SavePath; @@ -123,7 +119,7 @@ namespace Lantean.QBTMud.Helpers var addTorrentParams = CreateAddTorrentParams(options); addTorrentParams.Urls = options.Urls; - await apiClient.AddTorrent(addTorrentParams); + _ = await apiClient.AddTorrent(addTorrentParams); } public static async Task InvokeDeleteTorrentDialog(this IDialogService dialogService, IApiClient apiClient, params string[] hashes) @@ -243,7 +239,7 @@ namespace Lantean.QBTMud.Helpers var shareRatio = (ShareRatio)dialogResult.Data; - await apiClient.SetTorrentShareLimit(shareRatio.RatioLimit, shareRatio.SeedingTimeLimit, shareRatio.InactiveSeedingTimeLimit, null, torrents.Select(t => t.Hash).ToArray()); + await apiClient.SetTorrentShareLimit(shareRatio.RatioLimit, shareRatio.SeedingTimeLimit, shareRatio.InactiveSeedingTimeLimit, hashes: torrents.Select(t => t.Hash).ToArray()); } public static async Task InvokeStringFieldDialog(this IDialogService dialogService, string title, string label, string? value, Func onSuccess) @@ -436,4 +432,4 @@ namespace Lantean.QBTMud.Helpers await dialogService.ShowAsync(parent.Text, parameters, FormDialogOptions); } } -} \ No newline at end of file +} diff --git a/Lantean.QBTMud/Services/DataManager.cs b/Lantean.QBTMud/Services/DataManager.cs index c76e699..0737886 100644 --- a/Lantean.QBTMud/Services/DataManager.cs +++ b/Lantean.QBTMud/Services/DataManager.cs @@ -1738,7 +1738,7 @@ namespace Lantean.QBTMud.Services SocketReceiveBufferSize = changed.SocketReceiveBufferSize, SocketSendBufferSize = changed.SocketSendBufferSize, SsrfMitigation = changed.SsrfMitigation, - StartPausedEnabled = changed.StartPausedEnabled, + AddStoppedEnabled = changed.AddStoppedEnabled, StopTrackerTimeout = changed.StopTrackerTimeout, TempPath = changed.TempPath, TempPathEnabled = changed.TempPathEnabled, @@ -1944,7 +1944,7 @@ namespace Lantean.QBTMud.Services original.SocketReceiveBufferSize = changed.SocketReceiveBufferSize ?? original.SocketReceiveBufferSize; original.SocketSendBufferSize = changed.SocketSendBufferSize ?? original.SocketSendBufferSize; original.SsrfMitigation = changed.SsrfMitigation ?? original.SsrfMitigation; - original.StartPausedEnabled = changed.StartPausedEnabled ?? original.StartPausedEnabled; + original.AddStoppedEnabled = changed.AddStoppedEnabled ?? original.AddStoppedEnabled; original.StopTrackerTimeout = changed.StopTrackerTimeout ?? original.StopTrackerTimeout; original.TempPath = changed.TempPath ?? original.TempPath; original.TempPathEnabled = changed.TempPathEnabled ?? original.TempPathEnabled; @@ -2134,4 +2134,4 @@ namespace Lantean.QBTMud.Services return new RssList(feeds, articles); } } -} \ No newline at end of file +}