@page "/person/{Address}"
@inject State State
@inject IJSRuntime JS
@inject NavigationManager Nav
@Address
@if (bio == null) {
}
else {
@bio
}
@if(now != null){
}
@code {
private string _address;
[Parameter]
public string Address {
get => _address;
set {
_address = value;
if(StatusList != null) StatusList.StatusFunc = async () => await State.GetStatuses(_address);
if(PicList != null) PicList.PicsFunc = async () => await State.GetPics(_address);
}
}
public string ProfileUrl {
get => $"https://{Address}.omg.lol/";
}
public ExternalPageComponent? NowPage { get; set; }
public ExternalPageComponent? ProfilePage { get; set; }
private StatusList StatusList { get; set; }
private PicList PicList { get; set; }
private bool Editable {
get => Address == State.SelectedAddressName;
}
private MarkupString? bio;
private NowData? now;
protected override async Task OnInitializedAsync() {
List? garden = await State.GetNowGarden();
now = garden?.FirstOrDefault(n => n.Address == Address);
await InvokeAsync(StateHasChanged);
string fragment = new Uri(Nav.Uri).Fragment;
await JS.InvokeVoidAsync("ui", fragment);
if (fragment.EndsWith("now")) await ReloadNow();
else if (fragment.EndsWith("profile")) await ReloadProfile();
bio = await State.GetBio(Address);
}
private async Task ReloadNow() {
if(NowPage != null) {
await NowPage.Reload();
await ResizeIframes();
}
}
private async Task ReloadProfile() {
if (ProfilePage != null) {
await ProfilePage.Reload();
await ResizeIframes();
}
}
private async Task ResizeIframes() {
await JS.InvokeVoidAsync("iframeResize", new { license = "GPLv3" });
}
}