[frontend] Use renote endpoint, disable renotes where they aren't possible, add lock icon

This commit is contained in:
Lilian 2024-06-19 14:27:42 +02:00 committed by Laura Hausmann
parent d6c3fb028f
commit 56d5ff9e93
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 39 additions and 19 deletions

View file

@ -1,3 +1,4 @@
@using AngleSharp.Dom
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas
@inject ApiService ApiService;
@ -26,7 +27,14 @@
}
@if (!AsQuote)
{
<NoteFooter Reactions="Note.Reactions" Likes="Note.Likes" IsLiked="Note.Liked"/>
@* FIXME: Allow renotes when the post is from the current user *@
<NoteFooter
Reactions="Note.Reactions"
Likes="Note.Likes"
IsLiked="Note.Liked"
Renotes="Note.Renotes"
RenotePossible="@(Note.Visibility == NoteVisibility.Public || Note.Visibility == NoteVisibility.Home)"
/>
}
</CascadingValue>
@code {
@ -94,17 +102,9 @@
public void Renote()
{
var renote = new NoteCreateRequest
{
Text = "",
Cw = null,
ReplyId = null,
RenoteId = Note.Id,
MediaIds = null,
Visibility = Note.Visibility,
IdempotencyKey = null
};
ApiService.Notes.CreateNote(renote);
ApiService.Notes.RenoteNote(Note.Id);
Note.Renotes++;
StateHasChanged();
}
public void DoQuote()

View file

@ -14,13 +14,26 @@
<Icon Name="Icons.ArrowUUpLeft" Size="1.3em"/>
</button>
<button class="btn" @onclick="Renote" @onclick:stopPropagation="true">
<Icon Name="Icons.Repeat" Size="1.3em"/>
@if (RenotePossible)
{
<Icon Name="Icons.Repeat" Size="1.3em"/>
}
else
{
<Icon Name="Icons.Lock" Size="1.3em"/>
}
@if (Renotes > 0)
{
<span class="renote-count">@Renotes</span>
}
</button>
<button @onclick="Like" @onclick:stopPropagation="true" class="btn">
@if (IsLiked)
{
<Icon Name="Icons.Heart" Pack="IconStyle.Fill" Size="1.3em"/>
}else {
}
else
{
<Icon Name="Icons.Heart" Size="1.3em"/>
}
@if (Likes > 0)
@ -38,10 +51,13 @@
<Icon Name="Icons.DotsThreeOutline" Size="1.3em"/>
</button>
</div>
@code {
[Parameter] [EditorRequired] public required List<NoteReactionSchema> Reactions { get; set; }
[Parameter] [EditorRequired] public required int Likes { get; set; }
[Parameter] [EditorRequired] public required bool IsLiked { get; set; }
[Parameter] [EditorRequired] public required List<NoteReactionSchema> Reactions { get; set; }
[Parameter] [EditorRequired] public required int Likes { get; set; }
[Parameter] [EditorRequired] public required bool IsLiked { get; set; }
[Parameter] [EditorRequired] public required int Renotes { get; set; }
[Parameter] public bool RenotePossible { get; set; }
[CascadingParameter] NoteComponent NoteComponent { get; set; }
@ -57,11 +73,12 @@
private void Renote()
{
NoteComponent.Renote();
if (RenotePossible) NoteComponent.Renote();
}
private void Quote()
{
NoteComponent.DoQuote();
}
}

View file

@ -14,3 +14,6 @@
.like-count{
margin-left: 0.3em;
}
.renote-count {
margin-left: 0.3em;
}