[frontend] Add renotes to note detail view

This commit is contained in:
Lilian 2024-09-24 00:49:34 +02:00
parent f0cb04d5b7
commit a054080364
No known key found for this signature in database
3 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,62 @@
@using Iceshrimp.Frontend.Core.Miscellaneous
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas.Web
@inject ApiService Api;
@inject ILogger<NoteLikeDetails> Logger;
@inject NavigationManager Nav;
@if (State is State.Loaded)
{
<div class="renotes">
@if (RenotedBy != null) @foreach (var el in RenotedBy)
{
<div @onclick="() => OpenProfile(el.Username, el.Host)" class="renote-entry">
<img class="icon" src="@el.AvatarUrl"/>
<div class="name-section">
<div class="displayname">@el.DisplayName</div>
<div class="username">@@@el.Username@(el.Host != null ? $"@{el.Host}" : "")</div>
</div>
</div>
}
</div>
}
@if (State is State.Loading)
{
<span>Loading</span>
}
@if (State is State.Error)
{
<span>Failed to load</span>
}
@code {
[Parameter, EditorRequired] public required string NoteId { get; set; }
private State State { get; set; }
private List<UserResponse>? RenotedBy { get; set; } = [];
protected override async Task OnInitializedAsync()
{
try
{
RenotedBy = await Api.Notes.GetRenotes(NoteId);
State = State.Loaded;
}
catch (ApiException e)
{
Logger.LogError(e, "Failed to load likes");
State = State.Error;
}
}
private void OpenProfile(string username, string? host)
{
var path = $"@{username}";
if (host != null)
{
path += $"@{host}";
}
Nav.NavigateTo($"/{path}");
}
}

View file

@ -0,0 +1,18 @@
.icon {
border-radius: 8px;
object-fit: cover;
width: 2.5em;
height: 2.5em;
align-self: center;
}
.name-section {
margin-left: 0.25rem;
line-height: 1.25;
}
.renote-entry {
display: flex;
margin: 0.5rem 0.25rem;
cursor: pointer;
}

View file

@ -66,6 +66,12 @@
<NoteLikeDetails NoteId="@RootNote?.Id" />
</TabContent>
</TabPage>
<TabPage>
<Title>@Loc["Renotes ({0})", RootNote!.Renotes]</Title>
<TabContent>
<NoteRenoteDetails NoteId="@RootNote?.Id" />
</TabContent>
</TabPage>
<TabPage>
<Title>@Loc["Reactions ({0})", RootNote!.Reactions.Count]</Title>
<TabContent>