Repository navigation
Expand file tree
/
Copy pathApp.razor
More file actions
62 lines (57 loc) · 1.75 KB
/
Copy pathApp.razor
File metadata and controls
62 lines (57 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@inject EventEaseState State
@if (!initialized && initializationError is null)
{
<div class="app-loading" role="status">Loading EventEase…</div>
}
else if (initializationError is not null)
{
<div class="storage-error" role="alert">
<h1>EventEase could not load your browser data.</h1>
<p>@initializationError</p>
<button class="button button--primary" @onclick="Reload">Try again</button>
</div>
}
else
{
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
}
@code {
private bool initialized;
private string? initializationError;
protected override async Task OnInitializedAsync()
{
await LoadStateAsync();
}
private async Task Reload()
{
initializationError = null;
await LoadStateAsync();
}
private async Task LoadStateAsync()
{
try
{
await State.InitializeAsync();
initialized = true;
}
catch (JSException)
{
initializationError = "Browser storage is unavailable. Allow this site to use local and session storage, then try again.";
}
catch (System.Text.Json.JsonException)
{
initializationError = "Saved browser data is invalid. Clear this site's EventEase storage and reload the app.";
}
}
}