@page "/notes/{NoteId}" @using Iceshrimp.Frontend.Components @using Iceshrimp.Frontend.Components.Note @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Shared.Schemas.Web @inject ApiService ApiService @inject IJSRuntime Js @if (_init) {
@if (Ascendants != null) {
@foreach (var note in Ascendants) { }
}
@if (Descendants != null) {
@foreach (var element in Descendants) { }
}
} else {
Loading
} @if (_error) {
This note does not exist!
} @code { [Parameter] public string? NoteId { get; set; } public NoteResponse? RootNote { get; set; } private IList? Descendants { get; set; } private IList? Ascendants { get; set; } private IJSObjectReference? Module { get; set; } private ElementReference RootNoteRef { get; set; } private bool _init; private bool _error; protected override async Task OnParametersSetAsync() { _init = false; if (NoteId == null) { _error = true; return; } RootNote = await ApiService.Notes.GetNote(NoteId); if (RootNote == null) { _error = true; return; } Descendants = await ApiService.Notes.GetNoteDescendants(NoteId, default); Ascendants = await ApiService.Notes.GetNoteAscendants(NoteId, default); _init = true; StateHasChanged(); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { Module = await Js.InvokeAsync("import", "/Pages/SingleNote.razor.js"); } if (_init) { await (Module ?? throw new InvalidOperationException("JS interop not initialized")) .InvokeVoidAsync("ScrollIntoView", RootNoteRef); } } }