128 lines
No EOL
6.5 KiB
Text
128 lines
No EOL
6.5 KiB
Text
@* ReSharper disable once RedundantUsingDirective *@
|
|
@using Iceshrimp.Frontend.Components.Note
|
|
@using Iceshrimp.Frontend.Localization
|
|
@using Iceshrimp.Shared.Schemas.Web
|
|
@using Microsoft.Extensions.Localization
|
|
@using Iceshrimp.Assets.PhosphorIcons
|
|
@inject IStringLocalizer<Localization> Loc;
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<div class="notification">
|
|
@if (NotificationResponse is not { Type: "mention" } or { Type: "reply" })
|
|
{
|
|
<div class="notification-header">
|
|
@if (NotificationResponse is { User: not null })
|
|
{
|
|
<UserAvatar User="@NotificationResponse.User" OnClick="@OpenProfile"/>
|
|
}
|
|
|
|
<div class="notification-body">
|
|
@if (NotificationResponse is { User: not null })
|
|
{
|
|
<span @onclick="OpenProfile" class="display-name">
|
|
<UserDisplayName User="@NotificationResponse.User" />
|
|
</span>
|
|
}
|
|
|
|
@switch (NotificationResponse)
|
|
{
|
|
case { Note: not null, Type: "like", User: not null }:
|
|
<span class="notification-icon"><Icon Name="Icons.Heart" Pack="IconStyle.Fill" Size="0.8em"/></span>
|
|
<span class="notification-text">@Loc["liked note"]</span>
|
|
break;
|
|
case { Note: not null, Reaction: not null, Type: "reaction" }:
|
|
<span class="notification-reaction" title="@NotificationResponse.Reaction.Name">
|
|
<InlineEmoji Name="@NotificationResponse.Reaction.Name" Url="@NotificationResponse.Reaction.Url" Hover="true" Size="1.25em"/>
|
|
</span>
|
|
<span class="notification-text">@Loc["reacted to your note"]</span>
|
|
break;
|
|
case { Type: "follow", User: not null }:
|
|
<span class="notification-icon"><Icon Name="Icons.HandWaving" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["followed you"]</span>
|
|
break;
|
|
case { Type: "followRequestReceived" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Clock" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["requested to follow you"]</span>
|
|
break;
|
|
case { Type: "followRequestAccepted" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Check" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["accepted your follow request"]</span>
|
|
break;
|
|
case { Type: "renote" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Repeat" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["renoted your note"]</span>
|
|
break;
|
|
case { Type: "quote" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Quotes" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["quoted your note"]</span>
|
|
break;
|
|
case { Bite: { BiteBack: true }, Type: "bite" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Tooth" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["bit you back"]</span>
|
|
break;
|
|
case { Note: not null, Type: "bite" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Tooth" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["bit your note"]</span>
|
|
break;
|
|
case { Type: "bite" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Tooth" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["bit you"]</span>
|
|
break;
|
|
case { Type: "edit" }:
|
|
<span class="notification-icon"><Icon Name="Icons.PencilLine" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["edited a note"]</span>
|
|
break;
|
|
case { Type: "pollVote" }:
|
|
<span class="notification-icon"><Icon Name="Icons.MicrophoneStage" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["voted on your poll"]</span>
|
|
break;
|
|
case { Type: "pollEnded" }:
|
|
<span class="notification-icon"><Icon Name="Icons.Timer" Size="0.9em"/></span>
|
|
<span class="notification-text">@Loc["poll has ended"]</span>
|
|
break;
|
|
default:
|
|
<span class="notification-icon"><Icon Name="Icons.Question" Size="0.9em"/></span>
|
|
<span class="notification-text">
|
|
<i>@Loc["unsupported notification type"]</i>
|
|
</span>
|
|
<details>
|
|
<summary>view details</summary>
|
|
<p>ID: @NotificationResponse.Id</p>
|
|
<p>Type: @NotificationResponse.Type</p>
|
|
</details>
|
|
break;
|
|
}
|
|
</div>
|
|
|
|
<span><Timestamp Date="@DateTime.Parse(NotificationResponse.CreatedAt)"/></span>
|
|
</div>
|
|
}
|
|
|
|
@if (NotificationResponse is { Note: not null })
|
|
{
|
|
<div @onclick="OpenNote" class="@(NotificationResponse is not { Type: "mention" } or { Type: "reply" } ? "notification-note" : "")">
|
|
<NoteComponent Note="NotificationResponse.Note" AsQuote="@(NotificationResponse is not { Type: "mention" } or { Type: "reply" })"/>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public required NotificationResponse NotificationResponse { get; set; }
|
|
|
|
private void OpenNote()
|
|
{
|
|
NavigationManager.NavigateTo($"/notes/{NotificationResponse.Note!.Id}");
|
|
}
|
|
|
|
private void OpenFollowRequests()
|
|
{
|
|
NavigationManager.NavigateTo("/follow-requests");
|
|
}
|
|
|
|
private void OpenProfile()
|
|
{
|
|
var username = $"@{NotificationResponse.User?.Username}";
|
|
if (NotificationResponse.User?.Host != null) username += $"@{NotificationResponse.User.Host}";
|
|
NavigationManager.NavigateTo($"/{username}");
|
|
}
|
|
} |