37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Manager.App.Models.Library;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
|
|
namespace Manager.App.Components.Pages;
|
|
|
|
public partial class Library : ComponentBase
|
|
{
|
|
private LibraryInformation? _libraryInformation;
|
|
private bool _loading;
|
|
private CancellationTokenSource _cancellationTokenSource = new();
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
if (_cancellationTokenSource.IsCancellationRequested)
|
|
{
|
|
_cancellationTokenSource = new CancellationTokenSource();
|
|
}
|
|
|
|
_loading = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
var result = await LibraryService.GetLibraryInfoAsync(_cancellationTokenSource.Token);
|
|
if (result is { IsSuccess: true, Value: not null })
|
|
{
|
|
_libraryInformation = result.Value;
|
|
}
|
|
else
|
|
{
|
|
Snackbar.Add($"Failed to get library info. Error: {result.Error?.Description}", Severity.Error);
|
|
}
|
|
_loading = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
} |