77 lines
No EOL
2 KiB
Text
77 lines
No EOL
2 KiB
Text
@page "/notes/{NoteId}"
|
|
@using Iceshrimp.Shared.Schemas
|
|
@using Iceshrimp.Frontend.Components
|
|
@using Iceshrimp.Frontend.Core.Services
|
|
@using Iceshrimp.Frontend.Components.Note
|
|
@inject ApiService ApiService
|
|
|
|
@if (_init)
|
|
{
|
|
<div class="scroller">
|
|
<div class="wrapper">
|
|
@if (Ascendants != null)
|
|
{
|
|
<div class="ascendants">
|
|
@foreach (var note in Ascendants)
|
|
{
|
|
<AscendedNote Note="note"/>
|
|
}
|
|
</div>
|
|
}
|
|
<div class="root-note">
|
|
<Note NoteResponse="RootNote"></Note>
|
|
</div>
|
|
@if (Descendants != null)
|
|
{
|
|
<div class="descendants">
|
|
@foreach (var element in Descendants)
|
|
{
|
|
<RecursiveNote Note="element" Depth="0"/>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div>Loading</div>
|
|
}
|
|
@if (_error)
|
|
{
|
|
<div>This note does not exist!</div>
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public string? NoteId { get; set; }
|
|
public NoteResponse? RootNote { get; set; }
|
|
private IList<NoteResponse>? Descendants { get; set; }
|
|
private IList<NoteResponse>? Ascendants { get; set; }
|
|
private bool _init = false;
|
|
private bool _error = false;
|
|
|
|
protected override async Task OnInitializedAsync() { }
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
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();
|
|
}
|
|
|
|
} |