wabbajack/Wabbajack.App.Blazor/Pages/Gallery.razor
2022-01-17 00:46:16 +11:00

47 lines
1.3 KiB
Plaintext

@page "/gallery"
@namespace Wabbajack.App.Blazor.Pages
@using Wabbajack.Networking.WabbajackClientApi;
@using Wabbajack.DTOs
@using System.Diagnostics
@using Microsoft.Extensions.Logging
@using Wabbajack.App.Blazor.Models
@inject Client _client
<div id="content">
@foreach (ModlistMetadata item in _listItems)
{
<ModlistItem Metadata=@item></ModlistItem>
}
</div>
@code {
[Inject]
private ILogger<Gallery> _logger { get; set; }
// [Inject]
// private LoggerProvider _loggerProvider { get; set; }
[Inject]
private Services.OSIntegrated.Configuration _configuration { get; set; }
private List<ModlistMetadata> _listItems { get; set; } = new() { };
protected override async Task OnInitializedAsync()
{
try
{
_logger.LogInformation("Getting modlists...");
ModlistMetadata[] modLists = await _client.LoadLists();
_listItems.AddRange(modLists.ToList());
StateHasChanged();
}
catch (Exception ex)
{
//TODO: Figure out why an exception is thrown on first navigation.
Debug.Print(ex.Message);
_logger.LogError(ex, "Error while loading lists");
}
await base.OnInitializedAsync();
}
}