One sign-in for both of PrivaPub's APIs: the root logs in on /clientapi, picks a persona, and each persona gets its own Mastodon token in exchange for the JWT (PersonaExchange). HttpService picks credentials and JSON by route (JWT and camelCase for /clientapi, the persona token and snake_case for /api, nothing for /oauth), retries a refused persona token once, and records every request for the nerd stats. The feed page is three columns: navigation with a persona switcher, the feed with a tab per kind (home, local, federated, nearby, communities and circles, direct, notifications, favourites, bookmarks, hashtags), and a 3D globe that looks at the spherical mean of the posts in view and draws a pulse and an arc to a hovered one. Posts sit at their own place, their event's venue, the reader (located posts) or their author's server as PrivaPub publishes it. Cards favourite, boost, bookmark, reply, mute, block and delete; the composer posts with a content warning, visibility, media and alt text, or as a located post. Older pages load as the end nears; newer ones are polled while visible. Nerd stats in tooltips: provenance, author and server, place, media, counts, paging, the globe's camera and frame rate. The mock (Faker, MessagesService, the Message models and store) and the OIDC template leftovers are gone. Strings in English and Italian. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
131 lines
3.5 KiB
Plaintext
131 lines
3.5 KiB
Plaintext
@page "/expand/{statusId}"
|
|
@attribute [Authorize]
|
|
@inherits LocalizableComponentBase
|
|
<Title>@Localizer["Thread"]</Title>
|
|
|
|
@* A post with its thread (/api/v1/statuses/{id}/context): the posts it answers above, the post, the answers below.
|
|
The cards do their own actions; a reply or a deletion updates the thread here. *@
|
|
<section class="block relative w-full h-full neo-inset neo-xs rounded-xl">
|
|
<div class="flex flex-col gap-4 p-4 md:p-5 w-full h-full absolute overflow-y-auto">
|
|
|
|
<div class="flex items-center gap-2">
|
|
<DButton Size="DSize.Sm" OnClick="Back" title="@Localizer["Back"]">
|
|
<i class="ion-md-arrow-back"></i>
|
|
</DButton>
|
|
<h1 class="font-bold">@Localizer["Thread"]</h1>
|
|
</div>
|
|
|
|
@if (IsLoading)
|
|
{
|
|
<p class="flex w-full items-center justify-center gap-2">
|
|
<DLoading Variant="DLoadingVariant.Dots" LabelText="@Localizer["loading"]" />
|
|
@Localizer["loading"]
|
|
</p>
|
|
}
|
|
else if (current is null)
|
|
{
|
|
<p class="w-full text-center text-lg">
|
|
<i class="ion-ios-remove-circle-outline"></i> @Localizer["This message doesn't exist."]
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
@foreach (var post in ancestors)
|
|
{
|
|
<Content @key="post.Key" Post="post" CssContainer="ml-6 w-auto" OnDeleted="Remove" OnReplied="Replied" OnTag="OpenTag" />
|
|
}
|
|
|
|
<Content @key="current.Key" Post="current" Highlighted="true" IncludeExpand="false" OnDeleted="Remove" OnReplied="Replied" OnTag="OpenTag" />
|
|
|
|
@foreach (var post in descendants)
|
|
{
|
|
<Content @key="post.Key" Post="post" CssContainer="ml-6 w-auto" OnDeleted="Remove" OnReplied="Replied" OnTag="OpenTag" />
|
|
}
|
|
}
|
|
</div>
|
|
</section>
|
|
|
|
@code {
|
|
[Inject] StatusService StatusService { get; set; }
|
|
[Inject] InstanceService InstanceService { get; set; }
|
|
[Inject] ILocalStorageService LocalStorage { get; set; }
|
|
[Inject] IJSRuntime JS { get; set; }
|
|
|
|
[Parameter] public string StatusId { get; set; }
|
|
|
|
FeedPost current;
|
|
List<FeedPost> ancestors = [];
|
|
List<FeedPost> descendants = [];
|
|
string loadedId;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (StatusId == loadedId)
|
|
return;
|
|
loadedId = StatusId;
|
|
|
|
if (CascadingState.IsOffline)
|
|
{
|
|
WhenOnline(LoadData);
|
|
StartOnlinePolling();
|
|
IsLoading = false;
|
|
return;
|
|
}
|
|
|
|
await LoadData();
|
|
}
|
|
|
|
async Task LoadData()
|
|
{
|
|
IsLoading = true;
|
|
var status = await StatusService.Get(StatusId);
|
|
if (status is null)
|
|
{
|
|
current = null;
|
|
IsLoading = false;
|
|
return;
|
|
}
|
|
|
|
var context = await StatusService.Context(status.Id);
|
|
current = FeedPost.Of(status);
|
|
ancestors = [.. (context?.Ancestors ?? []).Select(FeedPost.Of)];
|
|
descendants = [.. (context?.Descendants ?? []).Select(FeedPost.Of)];
|
|
IsLoading = false;
|
|
|
|
var all = ancestors.Append(current).Concat(descendants).ToList();
|
|
await InstanceService.Resolve(all.Select(p => p.Host).Append(InstanceService.SelfHost));
|
|
InstanceService.Locate(all);
|
|
}
|
|
|
|
void Remove(FeedPost post)
|
|
{
|
|
if (post.Key == current?.Key)
|
|
{
|
|
current = null;
|
|
return;
|
|
}
|
|
ancestors.RemoveAll(p => p.Key == post.Key);
|
|
descendants.RemoveAll(p => p.Key == post.Key);
|
|
}
|
|
|
|
async Task Replied(FeedPost reply)
|
|
{
|
|
if (reply is null)
|
|
return;
|
|
descendants.Add(reply);
|
|
await InstanceService.Resolve([reply.Host]);
|
|
InstanceService.Locate([reply]);
|
|
}
|
|
|
|
async Task OpenTag(string tag)
|
|
{
|
|
var filter = await LocalStorage.GetItemAsync<FeedFilter>(nameof(FeedFilter)) ?? new();
|
|
filter.Tag = tag;
|
|
filter.TimelineType = TimelineType.Tag;
|
|
await LocalStorage.SetItemAsync(nameof(FeedFilter), filter);
|
|
Navigation.NavigateTo("");
|
|
}
|
|
|
|
async Task Back() => await JS.InvokeVoidAsync("history.back");
|
|
}
|