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

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

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
{ {

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

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;

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,7 +66,6 @@ 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)
{ {

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

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

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
{ {

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
{ {

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

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

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

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

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

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

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

@@ -130,5 +130,3 @@ namespace Lantean.QBTMudBlade.Pages
} }
} }
} }

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
{ {

View File

@@ -616,7 +616,6 @@ namespace Lantean.QBTMudBlade.Services
progress = (float)downloaded / size; progress = (float)downloaded / size;
} }
if (!contents.TryGetValue(key, out var dir)) if (!contents.TryGetValue(key, out var dir))
{ {
continue; continue;

View File

@@ -109,7 +109,6 @@ td.no-wrap {
} }
.field-switch { .field-switch {
} }
.piecesbarWrapper { .piecesbarWrapper {

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;

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

@@ -121,7 +121,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)
{ {
return apiClient.RecheckTorrents(null, hash); return apiClient.RecheckTorrents(null, hash);

View File

@@ -1,5 +1,4 @@
 namespace Lantean.QBitTorrentClient.Models
namespace Lantean.QBitTorrentClient.Models
{ {
public class SaveLocation public class SaveLocation
{ {