[CHANGE] Remove anon accounts && added simple caching for urls

This commit is contained in:
max
2025-09-17 23:44:02 +02:00
parent 0056a14f79
commit 8a64d6fc64
15 changed files with 235 additions and 50 deletions

View File

@@ -1,4 +1,6 @@
@using Manager.App.Services.System
@inject ISnackbar SnackbarService
@inject CacheService Cache
<ForcedLoadingOverlay Visible="_isLoading"/>
@@ -19,16 +21,15 @@
case AccountImportSteps.Authenticate:
<MudStack Spacing="2">
<MudPaper Elevation="0" Outlined Class="pa-2">
<MudSwitch @bind-Value="@IsAnonymous" Color="Color.Info">Anonymous client</MudSwitch>
<MudTextField @bind-Value="@DefaultUserAgent" Required Label="User agent"
HelperText="Use an WEB client user agent."/>
HelperText="Use an WEB user agent."/>
</MudPaper>
<MudStack Row Spacing="2" Style="height: 100%">
<MudPaper Elevation="0" Outlined Class="pa-2" Style="width: 50%;">
<MudText>Import cookies</MudText>
<MudText Typo="Typo.caption">@($"{ImportCookies.Count} cookie(s) imported")</MudText>
<MudForm @bind-IsValid="@_cookieImportTextValid" Disabled="@(IsAnonymous)">
<MudForm @bind-IsValid="@_cookieImportTextValid">
<MudTextField @bind-Value="@_cookieDomain" Immediate Required Label="Domain"
RequiredError="Domain is required."/>
<MudTextField Class="my-2" Lines="4" AutoGrow @bind-Value="@_cookieText" Immediate
@@ -76,7 +77,7 @@
<MudPaper Elevation="0">
@if (banner != null)
{
<MudImage Src="@banner.Url" Height="250" Style="width: 100%;"/>
<MudImage Src="@Cache.CreateCacheUrl(banner.Url)" Height="250" Style="width: 100%;"/>
}
else
{
@@ -85,7 +86,7 @@
<MudStack Row Spacing="3" Class="px-4">
@if (avatar != null)
{
<MudImage Src="@avatar.Url" Class="mt-n5" Height="100" Width="100"/>
<MudImage Src="@Cache.CreateCacheUrl(avatar.Url)" Class="mt-n5" Height="100" Width="100"/>
}
else
{

View File

@@ -10,7 +10,6 @@ namespace Manager.App.Components.Dialogs
{
[CascadingParameter] private IMudDialogInstance? MudDialog { get; set; }
[Parameter] public string DefaultUserAgent { get; set; } = "";
private bool IsAnonymous { get; set; }
private ClientPrep? PreparingClient { get; set; }
private CookieCollection ImportCookies { get; set; } = [];
private bool _isLoading;
@@ -22,12 +21,7 @@ namespace Manager.App.Components.Dialogs
private bool CanSave()
{
if (IsAnonymous || PreparingClient?.YouTubeClient?.State?.LoggedIn == true)
{
return true;
}
return false;
return PreparingClient?.YouTubeClient?.State?.LoggedIn == true;
}
private bool CanContinue()
@@ -35,13 +29,13 @@ namespace Manager.App.Components.Dialogs
switch (_steps)
{
case AccountImportSteps.Authenticate:
if (IsAnonymous || ImportCookies.Count != 0)
if (ImportCookies.Count != 0)
{
return true;
}
break;
case AccountImportSteps.Validate:
if (IsAnonymous || PreparingClient?.YouTubeClient?.State?.LoggedIn == true)
if (PreparingClient?.YouTubeClient?.State?.LoggedIn == true)
{
return true;
}
@@ -96,7 +90,6 @@ namespace Manager.App.Components.Dialogs
{
PreparingClient?.YouTubeClient?.Dispose();
PreparingClient = null;
IsAnonymous = false;
ImportCookies.Clear();
_steps = AccountImportSteps.Authenticate;
StateHasChanged();
@@ -150,10 +143,6 @@ namespace Manager.App.Components.Dialogs
{
_isLoading = true;
PreparingClient = new ClientPrep();
if (IsAnonymous)
{
ImportCookies.Clear();
}
var clientResult = await YouTubeClient.CreateAsync(ImportCookies, DefaultUserAgent);
if (clientResult.IsSuccess)
{