Neighbourhood.omg.lol/Components/Routes.razor
Gordon Pedersen df05e8a819 Made the api a singleton and got a share intent working
The result of the share intent needs more work, though.
2024-06-14 17:20:04 +10:00

31 lines
No EOL
1 KiB
Text

@using Microsoft.AspNetCore.Components.Authorization
@inject NavigationManager navigationManager
<Router AppAssembly="@typeof(MauiProgram).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
<Authorizing>Logging in...</Authorizing>
<NotAuthorized><RedirectToLogin /></NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<CascadingAuthenticationState>
<LayoutView Layout="@typeof(Layout.MainLayout)">
<img data-emoji="🦒" />
<p>Sorry, there's nothing here.</p>
</LayoutView>
</CascadingAuthenticationState>
</NotFound>
</Router>
@code
{
protected override void OnAfterRender(bool firstRender) {
string? shareString = Preferences.Get("shareString", null);
if (!string.IsNullOrWhiteSpace(shareString)) {
Preferences.Remove("shareString");
navigationManager.NavigateTo($"/sharetext/{shareString}");
}
}
}