@using Iceshrimp.Shared.Schemas.Web @using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Localization @using Microsoft.Extensions.Localization @inject IStringLocalizer Loc; @inject IJSRuntime Js; @if (NoteBase.Cw != null) {
@NoteBase.Cw
} @if (NoteBase.Cw == null) {
@if (_overHeight & !_showFull) { }
@if (ReplyInaccessible) { } @if (NoteBase.Attachments.Count > 0) { }
@if (_overHeight & _showFull) { }
} @code { [Parameter] public required NoteBase NoteBase { get; set; } [Parameter] public required bool OverLength { get; set; } [Parameter] public bool Indented { get; set; } [Parameter] public bool ReplyInaccessible { get; set; } private IJSObjectReference? Module { get; set; } private ElementReference Body { get; set; } private bool _showFull = false; private bool _cwToggle = true; private bool _overHeight = false; private bool _flag = false; protected override async Task OnInitializedAsync() { Module = await Js.InvokeAsync("import", "./Components/Note/NoteBody.razor.js"); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender == false) { if (Module != null && _flag == false) { var computedHeight = await Module.InvokeAsync("getComputedHeight", Body); if (computedHeight > 40) { _overHeight = true; StateHasChanged(); } _flag = true; } } } private void ToggleCw() { _cwToggle = !_cwToggle; StateHasChanged(); } private void ToggleTruncate() { _showFull = !_showFull; } }