Selector/Selector.MAUI/Pages/Launch.razor

35 lines
852 B
Plaintext

@page "/"
@using Selector.MAUI.Services;
@inject ILogger<Login> logger;
@inject NavigationManager NavManager;
@inject SessionManager sessionManager;
@inject HubManager hubManager;
@inject StartPageManager startManager;
<img class="spinning centered-spinning" src="/appicon.png" />
@code {
protected async override Task OnInitializedAsync()
{
logger.LogInformation("Starting up");
await sessionManager.LoadUserFromDisk();
if (sessionManager.IsLoggedIn)
{
await hubManager.EnsureConnected();
logger.LogInformation("User logged in, navigating to main app");
startManager.NavigateToStartPage();
}
else
{
logger.LogInformation("User not logged in, navigating to login");
NavManager.NavigateTo("/login");
}
}
}