Code cleanup

This commit is contained in:
ahjephson
2024-06-03 08:04:09 +01:00
parent b7c057468d
commit f49b876666
48 changed files with 73 additions and 87 deletions

View File

@@ -44,4 +44,4 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
MudDialog.Close(Tags); MudDialog.Close(Tags);
} }
} }
} }

View File

@@ -19,7 +19,7 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
public IEnumerable<string> Hashes { get; set; } = []; public IEnumerable<string> Hashes { get; set; } = [];
protected HashSet<string> Categories { get; set; } = []; protected HashSet<string> Categories { get; set; } = [];
protected IList<string> TorrentCategories { get; private set; } = []; protected IList<string> TorrentCategories { get; private set; } = [];
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()

View File

@@ -1,7 +1,6 @@
using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using MudBlazor; using MudBlazor;
using static MudBlazor.CategoryTypes;
namespace Lantean.QBTMudBlade.Components.Dialogs namespace Lantean.QBTMudBlade.Components.Dialogs
{ {
@@ -20,7 +19,7 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
public IEnumerable<string> Hashes { get; set; } = []; public IEnumerable<string> Hashes { get; set; } = [];
protected HashSet<string> Tags { get; set; } = []; protected HashSet<string> Tags { get; set; } = [];
protected IList<IReadOnlyList<string>> TorrentTags { get; private set; } = []; protected IList<IReadOnlyList<string>> TorrentTags { get; private set; } = [];
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()

View File

@@ -1,10 +1,6 @@
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Lantean.QBitTorrentClient.Models;
using Lantean.QBTMudBlade.Models;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using MudBlazor; using MudBlazor;
using System.Data.Common;
using static MudBlazor.CategoryTypes;
namespace Lantean.QBTMudBlade.Components namespace Lantean.QBTMudBlade.Components
{ {
@@ -237,7 +233,7 @@ namespace Lantean.QBTMudBlade.Components
protected string RowStyleFuncInternal(T item, int index) protected string RowStyleFuncInternal(T item, int index)
{ {
var style = "user-select: none; cursor: pointer;"; var style = "user-select: none; cursor: pointer;";
//EqualityComparer<T>.Default.Equals(item, SelectedItem) || //EqualityComparer<T>.Default.Equals(item, SelectedItem) ||
if (SelectedItems.Contains(item)) if (SelectedItems.Contains(item))
{ {
style += " background-color: var(--mud-palette-grey-dark); color: var(--mud-palette-grey-light) !important;"; style += " background-color: var(--mud-palette-grey-dark); color: var(--mud-palette-grey-light) !important;";

View File

@@ -35,4 +35,4 @@ namespace Lantean.QBTMudBlade.Components
await ErrorBoundary.RecoverAndClearErrors(); await ErrorBoundary.RecoverAndClearErrors();
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using MudBlazor; using MudBlazor;
using MudBlazor.Utilities; using MudBlazor.Utilities;
@@ -32,7 +31,6 @@ namespace Lantean.QBTMudBlade.Components
[Parameter] [Parameter]
public Color IconColor { get; set; } = Color.Default; public Color IconColor { get; set; } = Color.Default;
[Parameter] [Parameter]
public string? Target { get; set; } public string? Target { get; set; }
@@ -69,4 +67,4 @@ namespace Lantean.QBTMudBlade.Components
await OnClick.InvokeAsync(ev); await OnClick.InvokeAsync(ev);
} }
} }
} }

View File

@@ -192,7 +192,7 @@ namespace Lantean.QBTMudBlade.Components
{ {
files = await ApiClient.GetTorrentContents(Hash); files = await ApiClient.GetTorrentContents(Hash);
} }
catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden || exception.StatusCode == HttpStatusCode.NotFound)
{ {
_timerCancellationToken.CancelIfNotDisposed(); _timerCancellationToken.CancelIfNotDisposed();
return; return;
@@ -332,7 +332,7 @@ namespace Lantean.QBTMudBlade.Components
} }
return FileList!.Values.Where(f => f.Name.StartsWith(contentItem.Name + Extensions.DirectorySeparator) && !f.IsFolder); return FileList!.Values.Where(f => f.Name.StartsWith(contentItem.Name + Extensions.DirectorySeparator) && !f.IsFolder);
} }
private IEnumerable<ContentItem> GetChildren(ContentItem folder, int level) private IEnumerable<ContentItem> GetChildren(ContentItem folder, int level)
{ {

View File

@@ -1,8 +1,6 @@
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Models;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using MudBlazor;
using static MudBlazor.Colors;
namespace Lantean.QBTMudBlade.Components namespace Lantean.QBTMudBlade.Components
{ {
@@ -68,14 +66,13 @@ namespace Lantean.QBTMudBlade.Components
await CategoryChanged.InvokeAsync(category); await CategoryChanged.InvokeAsync(category);
} }
var tag = await LocalStorage.GetItemAsStringAsync(_tagSelectionStorageKey); var tag = await LocalStorage.GetItemAsStringAsync(_tagSelectionStorageKey);
if (tag is not null) if (tag is not null)
{ {
Tag = tag; Tag = tag;
await TagChanged.InvokeAsync(tag); await TagChanged.InvokeAsync(tag);
} }
var tracker = await LocalStorage.GetItemAsStringAsync(_trackerSelectionStorageKey); var tracker = await LocalStorage.GetItemAsStringAsync(_trackerSelectionStorageKey);
if (tracker is not null) if (tracker is not null)
{ {

View File

@@ -70,7 +70,7 @@ namespace Lantean.QBTMudBlade.Components
Pieces = await ApiClient.GetTorrentPieceStates(Hash); Pieces = await ApiClient.GetTorrentPieceStates(Hash);
Properties = await ApiClient.GetTorrentProperties(Hash); Properties = await ApiClient.GetTorrentProperties(Hash);
} }
catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden || exception.StatusCode == HttpStatusCode.NotFound)
{ {
_timerCancellationToken.CancelIfNotDisposed(); _timerCancellationToken.CancelIfNotDisposed();
return; return;

View File

@@ -1,7 +1,6 @@
using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient;
using Lantean.QBitTorrentClient.Models; using Lantean.QBitTorrentClient.Models;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using MudBlazor; using MudBlazor;
namespace Lantean.QBTMudBlade.Components namespace Lantean.QBTMudBlade.Components

View File

@@ -21,7 +21,7 @@ namespace Lantean.QBTMudBlade.Components
public bool Disabled { get; set; } public bool Disabled { get; set; }
/// <inheritdoc cref="MudBlazor.MudFormComponent{T}.Validation"/> /// <inheritdoc cref="MudBlazor.MudFormComponent{T}.Validation"/>
[Parameter] [Parameter]
public object? Validation { get; set; } public object? Validation { get; set; }
/// <inheritdoc cref="MudBlazor.MudField.HelperText"/> /// <inheritdoc cref="MudBlazor.MudField.HelperText"/>
@@ -34,4 +34,4 @@ namespace Lantean.QBTMudBlade.Components
await ValueChanged.InvokeAsync(value); await ValueChanged.InvokeAsync(value);
} }
} }
} }

View File

@@ -13,4 +13,4 @@ namespace Lantean.QBTMudBlade.Components
[Parameter] [Parameter]
public RenderFragment? ChildContent { get; set; } public RenderFragment? ChildContent { get; set; }
} }
} }

View File

@@ -55,7 +55,7 @@
return null; return null;
}; };
protected Func<int, string?> SlowTorrentDlRateThresholdValidation = value => protected Func<int, string?> SlowTorrentDlRateThresholdValidation = value =>
{ {
if (value < 1) if (value < 1)
@@ -150,7 +150,7 @@
MaxSeedingTimeEnabled = false; MaxSeedingTimeEnabled = false;
MaxSeedingTime = 1440; MaxSeedingTime = 1440;
} }
MaxRatioAct = Preferences.MaxRatioAct; MaxRatioAct = Preferences.MaxRatioAct;
if (Preferences.MaxInactiveSeedingTimeEnabled) if (Preferences.MaxInactiveSeedingTimeEnabled)

View File

@@ -1,6 +1,4 @@
using System.Numerics; namespace Lantean.QBTMudBlade.Components.Options
namespace Lantean.QBTMudBlade.Components.Options
{ {
public partial class ConnectionOptions : Options public partial class ConnectionOptions : Options
{ {
@@ -97,7 +95,7 @@ namespace Lantean.QBTMudBlade.Components.Options
MaxConnecEnabled = false; MaxConnecEnabled = false;
MaxConnec = 500; MaxConnec = 500;
} }
if (Preferences.MaxConnecPerTorrent > 0) if (Preferences.MaxConnecPerTorrent > 0)
{ {
MaxConnecPerTorrentEnabled = true; MaxConnecPerTorrentEnabled = true;
@@ -179,7 +177,7 @@ namespace Lantean.QBTMudBlade.Components.Options
protected void MaxConnecEnabledChanged(bool value) protected void MaxConnecEnabledChanged(bool value)
{ {
MaxConnecEnabled = value; MaxConnecEnabled = value;
} }
protected async Task MaxConnecChanged(int value) protected async Task MaxConnecChanged(int value)

View File

@@ -1,6 +1,4 @@
using ByteSizeLib; namespace Lantean.QBTMudBlade.Components.Options
namespace Lantean.QBTMudBlade.Components.Options
{ {
public partial class SpeedOptions : Options public partial class SpeedOptions : Options
{ {
@@ -149,7 +147,7 @@ namespace Lantean.QBTMudBlade.Components.Options
{ {
return; return;
} }
ScheduleFrom = value.Value; ScheduleFrom = value.Value;
bool hasChanged = false; bool hasChanged = false;
if (value.Value.Hours != Preferences?.ScheduleFromHour) if (value.Value.Hours != Preferences?.ScheduleFromHour)

View File

@@ -408,4 +408,4 @@ namespace Lantean.QBTMudBlade.Components.Options
await JSRuntime.Open(url, true); await JSRuntime.Open(url, true);
} }
} }
} }

View File

@@ -71,7 +71,7 @@ namespace Lantean.QBTMudBlade.Components
{ {
peers = await ApiClient.GetTorrentPeersData(Hash, _requestId); peers = await ApiClient.GetTorrentPeersData(Hash, _requestId);
} }
catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden || exception.StatusCode == HttpStatusCode.NotFound)
{ {
_timerCancellationToken.CancelIfNotDisposed(); _timerCancellationToken.CancelIfNotDisposed();
return; return;

View File

@@ -2,8 +2,8 @@
using Lantean.QBTMudBlade.Interop; using Lantean.QBTMudBlade.Interop;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using MudBlazor.Services;
using MudBlazor; using MudBlazor;
using MudBlazor.Services;
namespace Lantean.QBTMudBlade.Components namespace Lantean.QBTMudBlade.Components
{ {
@@ -25,7 +25,7 @@ namespace Lantean.QBTMudBlade.Components
[EditorRequired] [EditorRequired]
public IReadOnlyList<PieceState> Pieces { get; set; } = []; public IReadOnlyList<PieceState> Pieces { get; set; } = [];
[CascadingParameter(Name = "IsDarkMode")] [CascadingParameter(Name = "IsDarkMode")]
public bool IsDarkMode { get; set; } public bool IsDarkMode { get; set; }
[CascadingParameter] [CascadingParameter]
@@ -100,4 +100,4 @@ namespace Lantean.QBTMudBlade.Components
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
} }
} }

View File

@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using MudBlazor; using MudBlazor;
using MudBlazor.Utilities; using MudBlazor.Utilities;
using static MudBlazor.CategoryTypes;
namespace Lantean.QBTMudBlade.Components namespace Lantean.QBTMudBlade.Components
{ {
@@ -54,7 +53,6 @@ namespace Lantean.QBTMudBlade.Components
return; return;
} }
SortDirection sortDirection; SortDirection sortDirection;
switch (SortDirection) switch (SortDirection)
{ {

View File

@@ -4,7 +4,6 @@ using Lantean.QBTMudBlade.Interop;
using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Models;
using Lantean.QBTMudBlade.Services; using Lantean.QBTMudBlade.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using MudBlazor; using MudBlazor;
@@ -207,7 +206,7 @@ namespace Lantean.QBTMudBlade.Components
{ {
{ nameof(ManageTagsDialog.Hashes), Hashes } { nameof(ManageTagsDialog.Hashes), Hashes }
}; };
await DialogService.ShowAsync<ManageTagsDialog>("Manage Torrent Tags", parameters, DialogHelper.FormDialogOptions); await DialogService.ShowAsync<ManageTagsDialog>("Manage Torrent Tags", parameters, DialogHelper.FormDialogOptions);
} }
@@ -327,22 +326,27 @@ namespace Lantean.QBTMudBlade.Components
/// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper. /// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper.
/// </summary> /// </summary>
ToolbarContents, ToolbarContents,
/// <summary> /// <summary>
/// Renders a <see cref="MudToolBar"/>. /// Renders a <see cref="MudToolBar"/>.
/// </summary> /// </summary>
Toolbar, Toolbar,
/// <summary> /// <summary>
/// Renders a <see cref="MudMenu"/>. /// Renders a <see cref="MudMenu"/>.
/// </summary> /// </summary>
Menu, Menu,
/// <summary> /// <summary>
/// Renders a <see cref="MudToolBar"/> with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children. /// Renders a <see cref="MudToolBar"/> with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children.
/// </summary> /// </summary>
MixedToolbarContents, MixedToolbarContents,
/// <summary> /// <summary>
/// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children. /// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children.
/// </summary> /// </summary>
MixedToolbar, MixedToolbar,
InitialIconsOnly, InitialIconsOnly,
Children, Children,
} }

View File

@@ -24,4 +24,4 @@ namespace Lantean.QBTMudBlade.Components
return torrent; return torrent;
} }
} }
} }

View File

@@ -59,7 +59,7 @@ namespace Lantean.QBTMudBlade.Components
{ {
Trackers = await ApiClient.GetTorrentTrackers(Hash); Trackers = await ApiClient.GetTorrentTrackers(Hash);
} }
catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden || exception.StatusCode == HttpStatusCode.NotFound)
{ {
_timerCancellationToken.CancelIfNotDisposed(); _timerCancellationToken.CancelIfNotDisposed();
return; return;

View File

@@ -65,7 +65,7 @@ namespace Lantean.QBTMudBlade.Components
{ {
WebSeeds = await ApiClient.GetTorrentWebSeeds(Hash); WebSeeds = await ApiClient.GetTorrentWebSeeds(Hash);
} }
catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden || exception.StatusCode == HttpStatusCode.NotFound)
{ {
_timerCancellationToken.CancelIfNotDisposed(); _timerCancellationToken.CancelIfNotDisposed();
return; return;

View File

@@ -4,7 +4,6 @@ using Lantean.QBTMudBlade.Components.Dialogs;
using Lantean.QBTMudBlade.Filter; using Lantean.QBTMudBlade.Filter;
using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Models;
using MudBlazor; using MudBlazor;
using System.Collections.Generic;
namespace Lantean.QBTMudBlade namespace Lantean.QBTMudBlade
{ {
@@ -265,7 +264,7 @@ namespace Lantean.QBTMudBlade
return default; return default;
} }
return ((HashSet<string>, Dictionary<string, int?>))result.Data; return ((HashSet<string>, Dictionary<string, int?>))result.Data;
} }
public static async Task InvokeRssRulesDialog(this IDialogService dialogService) public static async Task InvokeRssRulesDialog(this IDialogService dialogService)
@@ -286,4 +285,4 @@ namespace Lantean.QBTMudBlade
await dialogService.ShowAsync<SubMenuDialog>(parent.Name, parameters, FormDialogOptions); await dialogService.ShowAsync<SubMenuDialog>(parent.Name, parameters, FormDialogOptions);
} }
} }
} }

View File

@@ -2,7 +2,6 @@
using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Models;
using MudBlazor; using MudBlazor;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text; using System.Text;
namespace Lantean.QBTMudBlade namespace Lantean.QBTMudBlade
@@ -341,32 +340,43 @@ namespace Lantean.QBTMudBlade
case "forcedMetaDL": case "forcedMetaDL":
case "downloading": case "downloading":
return (Icons.Material.Filled.Downloading, Color.Success); return (Icons.Material.Filled.Downloading, Color.Success);
case "forcedUP": case "forcedUP":
case "uploading": case "uploading":
return (Icons.Material.Filled.Upload, Color.Info); return (Icons.Material.Filled.Upload, Color.Info);
case "stalledUP": case "stalledUP":
return (Icons.Material.Filled.KeyboardDoubleArrowUp, Color.Info); return (Icons.Material.Filled.KeyboardDoubleArrowUp, Color.Info);
case "stalledDL": case "stalledDL":
return (Icons.Material.Filled.KeyboardDoubleArrowDown, Color.Success); return (Icons.Material.Filled.KeyboardDoubleArrowDown, Color.Success);
case "pausedDL": case "pausedDL":
return (Icons.Material.Filled.Pause, Color.Success); return (Icons.Material.Filled.Pause, Color.Success);
case "pausedUP": case "pausedUP":
return (Icons.Material.Filled.Pause, Color.Info); return (Icons.Material.Filled.Pause, Color.Info);
case "queuedDL": case "queuedDL":
case "queuedUP": case "queuedUP":
return (Icons.Material.Filled.Queue, Color.Default); return (Icons.Material.Filled.Queue, Color.Default);
case "checkingDL": case "checkingDL":
case "checkingUP": case "checkingUP":
return (Icons.Material.Filled.Loop, Color.Info); return (Icons.Material.Filled.Loop, Color.Info);
case "queuedForChecking": case "queuedForChecking":
case "checkingResumeData": case "checkingResumeData":
return (Icons.Material.Filled.Loop, Color.Warning); return (Icons.Material.Filled.Loop, Color.Warning);
case "moving": case "moving":
return (Icons.Material.Filled.Moving, Color.Info); return (Icons.Material.Filled.Moving, Color.Info);
case "error": case "error":
case "unknown": case "unknown":
case "missingFiles": case "missingFiles":
return (Icons.Material.Filled.Error, Color.Error); return (Icons.Material.Filled.Error, Color.Error);
default: default:
return (Icons.Material.Filled.QuestionMark, Color.Warning); return (Icons.Material.Filled.QuestionMark, Color.Warning);
} }

View File

@@ -81,7 +81,7 @@ namespace Lantean.QBTMudBlade
var propertyExpression = Expression.Property(parameterExpression, propertyInfo); var propertyExpression = Expression.Property(parameterExpression, propertyInfo);
var convertExpression = Expression.Convert(propertyExpression, typeof(object)); var convertExpression = Expression.Convert(propertyExpression, typeof(object));
return (Expression.Lambda<Func<T, object?>>(convertExpression, parameterExpression), propertyInfo.PropertyType); return (Expression.Lambda<Func<T, object?>>(convertExpression, parameterExpression), propertyInfo.PropertyType);
} }
} }

View File

@@ -1,5 +1,4 @@
using Lantean.QBTMudBlade; using Lantean.QBTMudBlade.Models;
using Lantean.QBTMudBlade.Models;
namespace Lantean.QBTMudBlade namespace Lantean.QBTMudBlade
{ {

View File

@@ -41,7 +41,7 @@ namespace Lantean.QBTMudBlade.Filter
propertyExpression.Modify<T>((Expression<Func<object?, bool>>)(x => (string?)x != null && value != null && ((string)x).StartsWith(value, stringComparer))), propertyExpression.Modify<T>((Expression<Func<object?, bool>>)(x => (string?)x != null && value != null && ((string)x).StartsWith(value, stringComparer))),
FilterOperator.String.EndsWith => FilterOperator.String.EndsWith =>
propertyExpression.Modify<T>((Expression<Func<object?, bool>>)(x => (string?)x != null && value != null && ((string)x).EndsWith(value, stringComparer))), propertyExpression.Modify<T>((Expression<Func<object?, bool>>)(x => (string?)x != null && value != null && ((string)x).EndsWith(value, stringComparer))),
FilterOperator.String.Empty => FilterOperator.String.Empty =>
propertyExpression.Modify<T>((Expression<Func<string?, bool>>)(x => string.IsNullOrWhiteSpace(x))), propertyExpression.Modify<T>((Expression<Func<string?, bool>>)(x => string.IsNullOrWhiteSpace(x))),
FilterOperator.String.NotEmpty => FilterOperator.String.NotEmpty =>
propertyExpression.Modify<T>((Expression<Func<string?, bool>>)(x => !string.IsNullOrWhiteSpace(x))), propertyExpression.Modify<T>((Expression<Func<string?, bool>>)(x => !string.IsNullOrWhiteSpace(x))),

View File

@@ -171,7 +171,6 @@ namespace Lantean.QBTMudBlade
public static bool FilterStatus(string state, long uploadSpeed, Status status) public static bool FilterStatus(string state, long uploadSpeed, Status status)
{ {
bool inactive = false; bool inactive = false;
switch (status) switch (status)
{ {

View File

@@ -26,7 +26,7 @@ namespace Lantean.QBTMudBlade.Interop
public static async Task RenderPiecesBar(this IJSRuntime runtime, string id, string hash, int[] pieces, string? downloadingColor = null, string? haveColor = null, string? borderColor = null) public static async Task RenderPiecesBar(this IJSRuntime runtime, string id, string hash, int[] pieces, string? downloadingColor = null, string? haveColor = null, string? borderColor = null)
{ {
await runtime.InvokeVoidAsync("qbt.renderPiecesBar", id, hash, pieces, downloadingColor, haveColor, borderColor ); await runtime.InvokeVoidAsync("qbt.renderPiecesBar", id, hash, pieces, downloadingColor, haveColor, borderColor);
} }
} }
} }

View File

@@ -18,7 +18,6 @@ namespace Lantean.QBTMudBlade.Layout
[CascadingParameter(Name = "SortDirection")] [CascadingParameter(Name = "SortDirection")]
public SortDirection SortDirection { get; set; } public SortDirection SortDirection { get; set; }
protected string? SelectedTorrent { get; set; } protected string? SelectedTorrent { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
@@ -34,4 +33,4 @@ namespace Lantean.QBTMudBlade.Layout
} }
} }
} }
} }

View File

@@ -23,4 +23,4 @@ namespace Lantean.QBTMudBlade.Layout
[CascadingParameter(Name = "SearchTermChanged")] [CascadingParameter(Name = "SearchTermChanged")]
public EventCallback<string> SearchTermChanged { get; set; } public EventCallback<string> SearchTermChanged { get; set; }
} }
} }

View File

@@ -21,7 +21,7 @@ namespace Lantean.QBTMudBlade.Models
Index = index; Index = index;
Priority = priority; Priority = priority;
Progress = progress; Progress = progress;
Size = size; Size = priority == Priority.DoNotDownload ? 0 : size;
Availability = availability; Availability = availability;
IsFolder = isFolder; IsFolder = isFolder;
Level = level; Level = level;

View File

@@ -32,11 +32,11 @@ namespace Lantean.QBTMudBlade.Pages
NavigationManager.NavigateTo("/"); NavigationManager.NavigateTo("/");
} }
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.BadRequest) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.BadRequest)
{ {
ApiError = "Invalid username or password."; ApiError = "Invalid username or password.";
} }
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.Forbidden) catch (HttpRequestException exception) when (exception.StatusCode == HttpStatusCode.Forbidden)
{ {
ApiError = "Requests from this client are currently unavailable."; ApiError = "Requests from this client are currently unavailable.";
} }
@@ -47,10 +47,12 @@ namespace Lantean.QBTMudBlade.Pages
} }
#if DEBUG #if DEBUG
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await DoLogin("admin", "23mIDZhvT"); await DoLogin("admin", "23mIDZhvT");
} }
#endif #endif
} }

View File

@@ -129,6 +129,4 @@ namespace Lantean.QBTMudBlade.Pages
UpdatePreferences = null; UpdatePreferences = null;
} }
} }
} }

View File

@@ -1,10 +1,9 @@
using Blazored.LocalStorage;
using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient;
using Lantean.QBTMudBlade.Services; using Lantean.QBTMudBlade.Services;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services; using MudBlazor.Services;
using Blazored;
using Blazored.LocalStorage;
namespace Lantean.QBTMudBlade namespace Lantean.QBTMudBlade
{ {
@@ -52,4 +51,4 @@ namespace Lantean.QBTMudBlade
await builder.Build().RunAsync(); await builder.Build().RunAsync();
} }
} }
} }

View File

@@ -28,4 +28,4 @@
} }
} }
} }
} }

View File

@@ -16,4 +16,4 @@ namespace Lantean.QBTMudBlade.Services
await _jSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text); await _jSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text);
} }
} }
} }

View File

@@ -615,7 +615,6 @@ namespace Lantean.QBTMudBlade.Services
downloaded = downloadingContents.Sum(c => c.Value.Downloaded); downloaded = downloadingContents.Sum(c => c.Value.Downloaded);
progress = (float)downloaded / size; progress = (float)downloaded / size;
} }
if (!contents.TryGetValue(key, out var dir)) if (!contents.TryGetValue(key, out var dir))
{ {

View File

@@ -46,4 +46,4 @@ namespace Lantean.QBTMudBlade.Services
elapsed.TotalMilliseconds.ToString("F1")); elapsed.TotalMilliseconds.ToString("F1"));
} }
} }
} }

View File

@@ -4,4 +4,4 @@
{ {
Task WriteToClipboard(string text); Task WriteToClipboard(string text);
} }
} }

View File

@@ -85,9 +85,9 @@ code {
padding-bottom: 0 !important; padding-bottom: 0 !important;
} }
.table-progress .progress-expand { .table-progress .progress-expand {
height: 28px !important; height: 28px !important;
} }
td.no-wrap { td.no-wrap {
white-space: nowrap; /* Prevent text from wrapping to the next line */ white-space: nowrap; /* Prevent text from wrapping to the next line */
@@ -109,7 +109,6 @@ td.no-wrap {
} }
.field-switch { .field-switch {
} }
.piecesbarWrapper { .piecesbarWrapper {

View File

@@ -49,6 +49,6 @@ window.qbt.renderPiecesBar = (id, hash, pieces, downloadingColor, haveColor, bor
const el = window.qbt.piecesBar.createElement(); const el = window.qbt.piecesBar.createElement();
parentElement.appendChild(el); parentElement.appendChild(el);
} }
window.qbt.piecesBar.setPieces(pieces); window.qbt.piecesBar.setPieces(pieces);
} }

View File

@@ -44,7 +44,6 @@ class PiecesBar {
MAX_CANVAS_WIDTH = 4096; MAX_CANVAS_WIDTH = 4096;
constructor(pieces, parameters) { constructor(pieces, parameters) {
this.id = 'piecesbar_' + (window.qbt.piecesBarUniqueId++); this.id = 'piecesbar_' + (window.qbt.piecesBarUniqueId++);
this.width = 0; this.width = 0;
this.height = 0; this.height = 0;
@@ -270,4 +269,4 @@ class PiecesBar {
window.qbt.PiecesBar = PiecesBar; window.qbt.PiecesBar = PiecesBar;
Object.freeze(window.qbt.PiecesBar); Object.freeze(window.qbt.PiecesBar);

View File

@@ -1,5 +1,4 @@
using Lantean.QBitTorrentClient.Models; using Lantean.QBitTorrentClient.Models;
using System;
using System.Net; using System.Net;
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Text.Json; using System.Text.Json;

View File

@@ -120,7 +120,6 @@ namespace Lantean.QBitTorrentClient
{ {
return apiClient.AddTorrentTags([tag], null, hashes.ToArray()); return apiClient.AddTorrentTags([tag], null, hashes.ToArray());
} }
public static Task RecheckTorrent(this IApiClient apiClient, string hash) public static Task RecheckTorrent(this IApiClient apiClient, string hash)
{ {

View File

@@ -12,4 +12,4 @@
return httpClient.GetAsync($"{requestUrl}{builder.ToQueryString()}"); return httpClient.GetAsync($"{requestUrl}{builder.ToQueryString()}");
} }
} }
} }

View File

@@ -1,5 +1,4 @@
 namespace Lantean.QBitTorrentClient.Models
namespace Lantean.QBitTorrentClient.Models
{ {
public class SaveLocation public class SaveLocation
{ {
@@ -79,4 +78,4 @@ namespace Lantean.QBitTorrentClient.Models
return ToValue().ToString(); return ToValue().ToString();
} }
} }
} }