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

182 lines
6 KiB
Text
Raw Normal View History

2024-05-30 01:06:08 +00:00
@page "/person/{Address}"
2024-06-06 05:20:09 +00:00
@inject State State
2024-06-11 00:36:48 +00:00
@inject IJSRuntime JS
@inject NavigationManager Nav
2024-06-11 00:36:48 +00:00
<RefreshButton></RefreshButton>
<div class="row center-align">
2024-06-13 06:35:40 +00:00
<h3 class="page-heading"><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>
2024-07-02 00:01:06 +00:00
@if (FeatureFlags.Following) {
2024-06-28 07:08:12 +00:00
<div class="row center-align">
@if (State.IsFollowing(Address)) {
2024-07-02 02:55:07 +00:00
<button id="follow-button" @onclick="async() => {await State.Unfollow(Address);await InvokeAsync(StateHasChanged);}">
2024-06-28 07:08:12 +00:00
<i class="fa-solid fa-minus"></i> Unfollow
</button>
}
else {
2024-07-02 02:55:07 +00:00
<button id="follow-button" @onclick="async() => {await State.Follow(Address);await InvokeAsync(StateHasChanged);}">
2024-06-28 07:08:12 +00:00
<i class="fa-solid fa-plus"></i> Follow
</button>
}
</div>
}
2024-06-05 12:41:08 +00:00
<div class="responsive">
2024-06-14 00:45:31 +00:00
<div class="tabs scroll">
2024-06-11 00:36:48 +00:00
<a data-ui="#profile" @onclick="ReloadProfile">
<i class="fa-solid fa-id-card"></i>
<span>@(Address).omg.lol</span>
</a>
2024-06-05 12:41:08 +00:00
<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>
2024-06-21 06:26:11 +00:00
@if(now != null || IsMe){
2024-06-11 00:36:48 +00:00
<a data-ui="#now" @onclick="ReloadNow">
<i class="fa-duotone fa-seedling"></i>
<span>/Now</span>
</a>
}
</div>
</div>
2024-06-11 00:36:48 +00:00
<div class="responsive page-container">
<div id="profile" class="page no-padding">
<a href="@ProfileUrl" target="_blank" class="hover absolute top right chip fill large-elevate">Open in browser <i class="fa-solid fa-arrow-up-right-from-square tiny"></i></a>
<ExternalPageComponent id="profile_page" @ref="ProfilePage" Url="@ProfileUrl"></ExternalPageComponent>
@if (IsMe) {
<a href="/editProfile" class="button fab circle extra large-elevate center-align middle-align">
<i class="square fa-solid fa-file-pen" style="line-height:56px;"></i>
<span>Edit</span>
</a>
}
2024-05-30 01:06:08 +00:00
</div>
2024-06-11 00:36:48 +00:00
2024-06-05 12:41:08 +00:00
<div id="statuses" class="page padding active">
@if(bio == null || !string.IsNullOrEmpty(bio.ToString())) {
<div id="info" class="box basis transparent">
<article id="bio" class="container shadowed blue-2-bg gray-9-fg">
@if (bio == null) {
<p><progress class="circle small"></progress></p>
}
else {
@bio
}
</article>
</div>
}
<StatusList @ref="StatusList" StatusFunc="@(async(refresh) => await State.GetStatuses(Address, refresh))" Editable="@IsMe"></StatusList>
@if(IsMe) {
2024-06-14 00:45:31 +00:00
<button class="fab circle extra large-elevate" data-ui="#post-modal">
<i class="fa-solid fa-pen-to-square"></i>
</button>
<NewStatusDialog id="post-modal"></NewStatusDialog>
}
2024-06-05 12:41:08 +00:00
</div>
<div id="pics" class="page padding">
<PicList @ref="PicList" PicsFunc="@(async(refresh) => await State.GetPics(Address, refresh))" Editable="@IsMe"></PicList>
@if (IsMe) {
2024-06-14 00:45:31 +00:00
<button class="fab circle extra large-elevate" data-ui="#post-modal">
<i class="fa-solid fa-camera-retro"></i>
</button>
<NewPicDialog id="post-modal"></NewPicDialog>
}
2024-06-05 12:41:08 +00:00
</div>
2024-06-21 06:26:11 +00:00
@if(now != null || IsMe){
2024-06-11 00:36:48 +00:00
<div id="now" class="page no-padding">
2024-06-21 06:26:11 +00:00
<a href="@NowPageUrl" target="_blank" class="hover absolute top right chip fill large-elevate">Open in browser <i class="fa-solid fa-arrow-up-right-from-square tiny"></i></a>
<ExternalPageComponent id="now_page" @ref="NowPage" Url="@NowPageUrl"></ExternalPageComponent>
@if (IsMe) {
<a href="/editNow" class="button fab circle extra large-elevate center-align middle-align">
<i class="square fa-solid fa-file-pen" style="line-height:56px;"></i>
<span>Edit</span>
</a>
}
2024-06-11 00:36:48 +00:00
</div>
}
2024-06-05 12:41:08 +00:00
</div>
2024-05-30 01:06:08 +00:00
@code {
2024-07-02 00:29:50 +00:00
private string _address = string.Empty;
2024-05-30 01:06:08 +00:00
[Parameter]
2024-06-13 10:02:51 +00:00
public string Address {
get => _address;
set {
_address = value;
if (StatusList != null) StatusList.StatusFunc = async (refresh) => await State.GetStatuses(_address, refresh);
if (PicList != null) PicList.PicsFunc = async (refresh) => await State.GetPics(_address, refresh);
2024-06-13 10:02:51 +00:00
}
}
2024-06-11 00:36:48 +00:00
public string ProfileUrl {
get => $"https://{Address}.omg.lol/";
}
2024-05-30 01:06:08 +00:00
2024-06-21 06:26:11 +00:00
public string NowPageUrl {
get => now?.Url ?? $"https://{Address}.omg.lol/now";
}
2024-06-11 00:36:48 +00:00
public ExternalPageComponent? NowPage { get; set; }
public ExternalPageComponent? ProfilePage { get; set; }
2024-06-07 04:25:21 +00:00
2024-07-02 00:29:50 +00:00
private StatusList? StatusList { get; set; }
private PicList? PicList { get; set; }
2024-06-13 10:02:51 +00:00
private bool IsMe {
2024-06-07 04:25:21 +00:00
get => Address == State.SelectedAddressName;
}
private MarkupString? bio;
2024-05-30 01:06:08 +00:00
2024-06-11 00:36:48 +00:00
private NowData? now;
2024-05-30 01:06:08 +00:00
protected override async Task OnInitializedAsync() {
List<NowData>? 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();
2024-06-06 05:20:09 +00:00
bio = await State.GetBio(Address);
2024-06-24 04:52:45 +00:00
State.PropertyChanged += StateChanged;
}
private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
using (State.GetRefreshToken()){
await ReloadNow();
await ReloadProfile();
bio = await State.GetBio(Address);
await InvokeAsync(StateHasChanged);
}
}
2024-06-11 00:36:48 +00:00
}
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" });
2024-06-05 12:41:08 +00:00
}
2024-05-30 01:06:08 +00:00
}