Iceshrimp.NET/Iceshrimp.Frontend/Pages/Note.razor
2024-04-01 21:24:29 +02:00

44 lines
No EOL
913 B
Text

@page "/notes/{id}"
@using Iceshrimp.Frontend.Core.Miscellaneous
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas
@inject ApiService Api
<h3>Authenticated note preview</h3>
@if (_note != null)
{
<p id="text">@_note.Text</p>
}
else if (_error != null)
{
<p>Error!: @_error.Error</p>
}
else
{
<p>Fetching note...</p>
}
@code {
[Parameter]
public string Id { get; set; } = null!;
private ErrorResponse? _error;
private NoteResponse? _note;
protected override async Task OnInitializedAsync()
{
try
{
_note = await Api.Notes.GetNote(Id) ?? throw new ApiException(new ErrorResponse
{
StatusCode = 404,
Error = "Note not found",
RequestId = "-"
});
}
catch (ApiException e)
{
_error = e.Response;
}
}
}