@using Iceshrimp.Frontend.Core.Services.NoteStore
@using Iceshrimp.Shared.Schemas.Web
@inject NoteActions NoteActions;
<button @onclick="React" class="reaction @(Reaction.Reacted ? "reacted" : "")" title="@Reaction.Name">
    <InlineEmoji Name="@Reaction.Name" Url="@Reaction.Url" Wide="true"/>
    <span class="count">
        @Reaction.Count
    </span>
</button>

@code {
    [Parameter] [EditorRequired] public required NoteReactionSchema Reaction { get; set; }
    [CascadingParameter]                         NoteBase               Note     { get; set; } = null!;

    private void React()
    {
        if (Reaction.Reacted) _ = NoteActions.RemoveReactAsync(Note, Reaction.Name);
        else _                  = NoteActions.AddReactAsync(Note, Reaction.Name, Reaction.Sensitive, Reaction.Url);
    }
}