@* ReSharper disable once RedundantUsingDirective *@ @using Iceshrimp.Frontend.Components.Note @using Iceshrimp.Frontend.Localization @using Iceshrimp.Shared.Schemas.Web @using Microsoft.Extensions.Localization @inject IStringLocalizer Loc; @inject NavigationManager NavigationManager
@if (NotificationResponse is { User: not null }) { }
@if (NotificationResponse is { User: not null }) { @(NotificationResponse.User.DisplayName ?? NotificationResponse.User.Username) } @if (NotificationResponse is { Note: not null, Type: "like", User: not null }) { @Loc["liked your post: "] } else if (NotificationResponse is { Note: not null, Type: "reaction" }) { @Loc["reacted to your post:"] } else if (NotificationResponse is { Type: "follow", User: not null }) { @Loc["Followed you."] } else if (NotificationResponse is { Type: "followRequestReceived" }) { @Loc["Requested to follow you."] } else if (NotificationResponse is { Type: "followRequestAccepted" }) { @Loc["Accepted your follow request."] } else if (NotificationResponse is { Type: "mention" }) { @Loc["mentioned you:"] } else if (NotificationResponse is { Type: "reply" }) { @Loc["replied to your post:"] } else if (NotificationResponse is { Type: "renote" }) { @Loc["boosted your post:"] } else if (NotificationResponse is { Type: "quote" }) { @Loc["quoted your post:"] } else if (NotificationResponse is { Bite: { BiteBack: true }, Type: "bite" }) { @Loc["bit you back"] } else if (NotificationResponse is { Note: not null, Type: "bite" }) { @Loc["bit your note:"] } else if (NotificationResponse is { Type: "bite" }) { @Loc["bit you"] } else { @Loc["unsupported notification type"]
view details

ID: @NotificationResponse.Id

Type: @NotificationResponse.Type

}
@RenderDate(DateTime.Parse(NotificationResponse.CreatedAt))
@if (NotificationResponse is { Note: not null }) {
}
@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}"); } // TODO: Deduplicate this and NoteMetadata.RenderDate private string RenderDate(DateTime date) { var diff = DateTime.Now - date; return diff switch { { TotalDays: >= 365 } => Loc["{0}y", Math.Round(diff.TotalDays / 365)], { TotalDays: >= 30 } => Loc["{0}mo", Math.Round(diff.TotalDays / 30)], { TotalDays: >= 7 } => Loc["{0}d", Math.Round(diff.TotalDays / 7)], { TotalDays: >= 1 } => Loc["{0}d", Math.Round(diff.TotalDays)], { TotalHours: >= 1 } => Loc["{0}h", Math.Round(diff.TotalHours)], { TotalMinutes: >= 1 } => Loc["{0}m", Math.Round(diff.TotalMinutes)], { TotalSeconds: >= 1 } => Loc["{0}s", Math.Round(diff.TotalSeconds)], _ => Loc["Just now"] }; } }