[frontend] Add renotes to note detail view
This commit is contained in:
parent
f0cb04d5b7
commit
a054080364
3 changed files with 86 additions and 0 deletions
62
Iceshrimp.Frontend/Components/NoteRenoteDetails.razor
Normal file
62
Iceshrimp.Frontend/Components/NoteRenoteDetails.razor
Normal 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}");
|
||||
}
|
||||
}
|
18
Iceshrimp.Frontend/Components/NoteRenoteDetails.razor.css
Normal file
18
Iceshrimp.Frontend/Components/NoteRenoteDetails.razor.css
Normal 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;
|
||||
}
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue