Update to use v5 api only.

This commit is contained in:
ahjephson
2025-10-21 13:38:50 +01:00
parent 8dd29c238d
commit c390d83e4d
9 changed files with 39 additions and 57 deletions

View File

@@ -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;

View File

@@ -65,8 +65,8 @@
{
return __builder =>
{
<MudMenuItem Icon="@Icons.Material.Filled.PlayArrow" IconColor="Color.Success" OnClick="@(e => ResumeTorrents(type))">Resume torrents</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Pause" IconColor="Color.Warning" OnClick="@(e => PauseTorrents(type))">Pause torrents</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.PlayArrow" IconColor="Color.Success" OnClick="@(e => StartTorrents(type))">Start torrents</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Pause" IconColor="Color.Warning" OnClick="@(e => StopTorrents(type))">Stop torrents</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Delete" IconColor="Color.Error" OnClick="@(e => RemoveTorrents(type))">Remove torrents</MudMenuItem>
};
}

View File

@@ -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)

View File

@@ -19,7 +19,7 @@
<FieldSwitch Label="Add to top of queue" Value="AddToTopOfQueue" ValueChanged="AddToTopOfQueueChanged" />
</MudItem>
<MudItem xs="12">
<FieldSwitch Label="Do not start the download automatically" Value="StartPausedEnabled" ValueChanged="StartPausedEnabledChanged" />
<FieldSwitch Label="Do not start the download automatically" Value="AddStoppedEnabled" ValueChanged="AddStoppedEnabledChanged" />
</MudItem>
<MudItem xs="12">
<MudSelect T="string" Label="Torrent stop condition" Value="TorrentStopCondition" ValueChanged="TorrentStopConditionChanged" Variant="Variant.Outlined">

View File

@@ -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);
}

View File

@@ -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()

View File

@@ -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()

View File

@@ -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<QBitTorrentClient.Models.TorrentContentLayout>(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<bool> 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<string, Task> onSuccess)

View File

@@ -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;