@page "/directory" @implements IDisposable @inject IJSRuntime JS @inject State State Welcome to the omg.lol member directory! Everyone here is awesome.
@if (addresses != null) { @* TODO: Display avatar and address name, grouped by starting letter? *@ }
@code { private List? addresses; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); if (addresses == null || addresses.Count == 0) addresses = await State.GetDirectory(); State.PropertyChanged += StateChanged; State.CanRefresh = true; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("removeElementById", "address-loading"); } private async void StateChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { addresses = await State.GetDirectory(true); State.IsRefreshing = false; } } public void Dispose() { State.PropertyChanged -= StateChanged; State.CanRefresh = false; } }