Iceshrimp.NET/Iceshrimp.Frontend/Components/Note/NoteComponent.razor
2024-11-05 16:57:25 +10:00

50 lines
1.7 KiB
Text

@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas.Web
@inject ApiService ApiService;
@inject NavigationManager NavigationManager
@inject ComposeService ComposeService
@inject SessionService Session;
<div class="note-header">
<NoteUserInfo User="@Note.User" Indented="Indented"/>
<NoteMetadata
Visibility="@Note.Visibility"
InstanceName="@Note.User.InstanceName"
CreatedAt="DateTime.Parse(Note.CreatedAt)">
</NoteMetadata>
</div>
<NoteBody NoteBase="Note" OverLength="@CheckLen()" Indented="Indented" ReplyInaccessible="ReplyInaccessible"/>
@if (Quote != null)
{
<div @onclick="OpenQuote" @onclick:stopPropagation="true" class="quote">
<NoteComponent Note="Quote" AsQuote="true"></NoteComponent>
</div>
}
@if (!AsQuote)
{
<NoteFooter
Reactions="Note.Reactions"
Likes="Note.Likes"
IsLiked="Note.Liked"
Renotes="Note.Renotes"
Replies="Note.Replies"
RenotePossible=
"@(Note.Visibility == NoteVisibility.Public || Note.Visibility == NoteVisibility.Home || Session.Current?.Id == Note.User.Id)"/>
}
@code {
[Parameter] [EditorRequired] public required NoteBase Note { get; set; }
[Parameter] public bool Indented { get; set; }
[Parameter] public NoteBase? Quote { get; set; }
[Parameter] public bool AsQuote { get; set; }
[Parameter] public bool ReplyInaccessible { get; set; }
private bool CheckLen()
{
return Note.Text?.Length > 500;
}
private void OpenQuote()
{
NavigationManager.NavigateTo($"/notes/{Quote!.Id}");
}
}