@using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Core.Miscellaneous @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Iceshrimp.Shared.Schemas.Web @using Microsoft.Extensions.Localization @inject GlobalComponentSvc Global; @inject IStringLocalizer Loc;
@if (Attachment.ContentType.StartsWith("image") || Constants.CommonImageExtensions.Any(e => Attachment.FileName.EndsWith(e))) { @Attachment.AltText } else if (BlurImage) {
@Loc["Sensitive media"] @Loc["Click to reveal"]
} // else if (Attachment.ContentType == "audio/x-mod") // { // TODO: Module player // } else if (Attachment.ContentType.StartsWith("audio") || Constants.CommonAudioExtensions.Any(e => Attachment.FileName.EndsWith(e))) { } else if (Attachment.ContentType.StartsWith("video") || Constants.CommonVideoExtensions.Any(e => Attachment.FileName.EndsWith(e))) { } else { } @if (!string.IsNullOrWhiteSpace(Attachment.AltText)) { } else { }
@code { [Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; } [Parameter] [EditorRequired] public required EventCallback OnOpen { get; set; } private bool BlurImage { get; set; } private void Open() { if (BlurImage) { BlurImage = false; StateHasChanged(); } else if (Attachment.ContentType.StartsWith("image")) { OnOpen.InvokeAsync(Attachment); } } protected override void OnParametersSet() { BlurImage = Attachment.IsSensitive; } private async Task DisplayAlt() { if (string.IsNullOrWhiteSpace(Attachment.AltText)) await Global.NoticeDialog?.Display(Loc["No alt text"], NoticeDialog.NoticeType.Error)!; else await Global.NoticeDialog?.Display(Attachment.AltText)!; } }