diff --git a/Manager.App/Components/Dialogs/AccountDialog.razor b/Manager.App/Components/Dialogs/AccountDialog.razor
index 5134465..38dfaee 100644
--- a/Manager.App/Components/Dialogs/AccountDialog.razor
+++ b/Manager.App/Components/Dialogs/AccountDialog.razor
@@ -5,9 +5,9 @@
@{
- var client = PreparingClient?.YouTubeClient;
+ var client = ClientChannel?.YouTubeClient;
var clientState = client?.State;
- var channel = PreparingClient?.Channel;
+ var channel = ClientChannel?.Channel;
var avatar = channel?.AvatarImages.FirstOrDefault();
var banner = channel?.BannerImages.FirstOrDefault();
}
diff --git a/Manager.App/Components/Dialogs/AccountDialog.razor.cs b/Manager.App/Components/Dialogs/AccountDialog.razor.cs
index 8f1897b..0876442 100644
--- a/Manager.App/Components/Dialogs/AccountDialog.razor.cs
+++ b/Manager.App/Components/Dialogs/AccountDialog.razor.cs
@@ -10,7 +10,7 @@ namespace Manager.App.Components.Dialogs
{
[CascadingParameter] private IMudDialogInstance? MudDialog { get; set; }
[Parameter] public string DefaultUserAgent { get; set; } = "";
- private ClientPrep? PreparingClient { get; set; }
+ private ClientChannel? ClientChannel { get; set; }
private CookieCollection ImportCookies { get; set; } = [];
private bool _isLoading;
private AccountImportSteps _steps = AccountImportSteps.Authenticate;
@@ -21,7 +21,7 @@ namespace Manager.App.Components.Dialogs
private bool CanSave()
{
- return PreparingClient?.YouTubeClient?.State?.LoggedIn == true;
+ return ClientChannel?.YouTubeClient?.State?.LoggedIn == true;
}
private bool CanContinue()
@@ -35,7 +35,7 @@ namespace Manager.App.Components.Dialogs
}
break;
case AccountImportSteps.Validate:
- if (PreparingClient?.YouTubeClient?.State?.LoggedIn == true)
+ if (ClientChannel?.YouTubeClient?.State?.LoggedIn == true)
{
return true;
}
@@ -61,7 +61,7 @@ namespace Manager.App.Components.Dialogs
case AccountImportSteps.Validate:
if (CanSave())
{
- MudDialog?.Close(DialogResult.Ok(PreparingClient));
+ MudDialog?.Close(DialogResult.Ok(ClientChannel));
await InvokeAsync(StateHasChanged);
return;
}
@@ -88,8 +88,8 @@ namespace Manager.App.Components.Dialogs
private void ClearPreparedClient()
{
- PreparingClient?.YouTubeClient?.Dispose();
- PreparingClient = null;
+ ClientChannel?.YouTubeClient?.Dispose();
+ ClientChannel = null;
ImportCookies.Clear();
_steps = AccountImportSteps.Authenticate;
StateHasChanged();
@@ -142,24 +142,24 @@ namespace Manager.App.Components.Dialogs
private async Task BuildClient()
{
_isLoading = true;
- PreparingClient = new ClientPrep();
+ ClientChannel = new ClientChannel();
var clientResult = await YouTubeClient.CreateAsync(ImportCookies, DefaultUserAgent);
if (clientResult.IsSuccess)
{
- PreparingClient.YouTubeClient = clientResult.Value;
+ ClientChannel.YouTubeClient = clientResult.Value;
}
- if (PreparingClient.YouTubeClient == null)
+ if (ClientChannel.YouTubeClient == null)
{
SnackbarService.Add("Failed to get client!", Severity.Error);
_isLoading = false;
return;
}
- var accountResult = await PreparingClient.YouTubeClient.GetChannelByIdAsync(PreparingClient.YouTubeClient.Id);
+ var accountResult = await ClientChannel.YouTubeClient.GetChannelByIdAsync(ClientChannel.YouTubeClient.Id);
if (accountResult.IsSuccess)
{
- PreparingClient.Channel = accountResult.Value;
+ ClientChannel.Channel = accountResult.Value;
}
_isLoading = false;
await InvokeAsync(StateHasChanged);
diff --git a/Manager.App/Components/Pages/Channels.razor.cs b/Manager.App/Components/Pages/Channels.razor.cs
index 7ac4ec9..36126f0 100644
--- a/Manager.App/Components/Pages/Channels.razor.cs
+++ b/Manager.App/Components/Pages/Channels.razor.cs
@@ -29,7 +29,7 @@ public partial class Channels : ComponentBase
return;
}
- var clientPrep = (ClientPrep)result.Data;
+ var clientPrep = (ClientChannel)result.Data;
if (clientPrep?.YouTubeClient == null)
{
return;
diff --git a/Manager.App/Controllers/CacheController.cs b/Manager.App/Controllers/CacheController.cs
index f77fde4..a78d1fd 100644
--- a/Manager.App/Controllers/CacheController.cs
+++ b/Manager.App/Controllers/CacheController.cs
@@ -8,14 +8,14 @@ namespace Manager.App.Controllers;
public class CacheController(ILogger logger, CacheService cacheService) : ControllerBase
{
[HttpGet]
- public async Task Cache([FromQuery(Name = "url")] string url)
+ public async Task Cache([FromQuery(Name = "url")] string url, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(url))
{
return BadRequest("No url given.");
}
- var cacheResult = await cacheService.CacheFromUrl(url);
+ var cacheResult = await cacheService.CacheFromUrl(url, cancellationToken);
if (!cacheResult.IsSuccess)
{
logger.LogError("Cache request failed. {ErrorMessage}", cacheResult.Error?.Description);
diff --git a/Manager.App/Models/Library/ClientPrep.cs b/Manager.App/Models/Library/ClientPrep.cs
deleted file mode 100644
index 6a965e4..0000000
--- a/Manager.App/Models/Library/ClientPrep.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Manager.YouTube;
-using Manager.YouTube.Models.Innertube;
-
-namespace Manager.App.Models.Library;
-
-public class ClientPrep
-{
- public YouTubeClient? YouTubeClient { get; set; }
- public Channel? Channel { get; set; }
-}
\ No newline at end of file
diff --git a/Manager.App/Services/System/ClientService.cs b/Manager.App/Services/System/ClientService.cs
index f91b83f..24aec88 100644
--- a/Manager.App/Services/System/ClientService.cs
+++ b/Manager.App/Services/System/ClientService.cs
@@ -1,6 +1,7 @@
using System.Net;
using DotBased.Logging;
using DotBased.Monads;
+using Manager.App.Models.Library;
using Manager.Data.Entities.LibraryContext;
using Manager.YouTube;
using Manager.YouTube.Models.Innertube;
@@ -10,7 +11,7 @@ namespace Manager.App.Services.System;
public class ClientService(IServiceScopeFactory scopeFactory, ILogger logger)
: ExtendedBackgroundService(nameof(ClientService), "Managing YouTube clients", logger, TimeSpan.FromMinutes(10))
{
- private readonly List _loadedClients = [];
+ private readonly List _loadedClients = [];
private CancellationToken _cancellationToken;
private ILibraryService? _libraryService;