Neighbourhood.omg.lol/Components/Pages/Person.razor

72 lines
2.1 KiB
Text

@page "/person/{Address}"
<div class="row center-align">
<h3><i class="fa-solid fa-fw fa-at"></i>@Address</h3>
</div>
<div class="row center-align">
<img class="profile avatar" src="https://profiles.cache.lol/@Address/picture" alt="@Address" />
</div>
<div id="bio" class="center-align max">
@if (bio == null)
{
<p><em>Getting Bio...</em></p>
}
else {
@bio
}
</div>
<div class="responsive">
<div class="tabs">
<a data-ui="#statuses" class="active">
<i class="fa-solid fa-message-smile"></i>
<span>Status.lol</span>
</a>
<a data-ui="#pics">
<i class="fa-solid fa-images"></i>
<span>Some.pics</span>
</a>
</div>
<div id="statuses" class="page padding active">
<StatusList StatusFunc="@GetStatuses"></StatusList>
</div>
<div id="pics" class="page padding">
<PicList PicsFunc="@GetPics"></PicList>
</div>
</div>
@code {
[Parameter]
public string Address { get; set; }
private Status[] statuses;
private MarkupString? bio;
protected override async Task OnInitializedAsync() {
RestService api = new RestService();
await GetBioAsync(api);
}
private async Task GetBioAsync(RestService api) {
bio = await api.StatuslogBio(Address);
}
public async ValueTask<ItemsProviderResult<Status>> GetStatuses(ItemsProviderRequest request) {
// TODO: request.cancellationToken
RestService api = new RestService();
statuses = (await api.Statuslog(Address)).ToArray() ?? new Status[0];
var numStatuses = Math.Min(request.Count, statuses.Length - request.StartIndex);
return new ItemsProviderResult<Status>(statuses.Skip(request.StartIndex).Take(numStatuses), statuses.Length);
}
private List<Pic> pics;
private async ValueTask<ItemsProviderResult<Pic>> GetPics(ItemsProviderRequest request) {
// TODO: request.cancellationToken
RestService api = new RestService();
if (pics == null || pics.Count == 0) pics = await api.SomePics(Address);
var numPics = Math.Min(request.Count, pics.Count - request.StartIndex);
return new ItemsProviderResult<Pic>(pics.Skip(request.StartIndex).Take(numPics), pics.Count);
}
}