[frontend] Use renote endpoint, disable renotes where they aren't possible, add lock icon
This commit is contained in:
parent
d6c3fb028f
commit
56d5ff9e93
3 changed files with 39 additions and 19 deletions
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -14,3 +14,6 @@
|
|||
.like-count{
|
||||
margin-left: 0.3em;
|
||||
}
|
||||
.renote-count {
|
||||
margin-left: 0.3em;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue