Iceshrimp.NET/Iceshrimp.Frontend/Pages/Note.razor
2024-06-19 01:56:51 +02:00

45 lines
No EOL
950 B
Text

@page "/Note/{id}"
@using Iceshrimp.Frontend.Core.Miscellaneous
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas
@using Iceshrimp.Frontend.Components
@inject ApiService Api
<h3>Authenticated note preview</h3>
@if (_note != null)
{
<TimelineNote Note="_note" />
}
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;
}
}
}