@page "/expand/{messageId}"
@Localizer
@code {
[CascadingParameter] IStringLocalizer Localizer { get; set; }
[Inject] NavigationManager Navigation { get; set; }
[Inject] IStorage DbStorage { get; set; }
[SupplyParameterFromQuery] string messageId { get; set; }
List Messages { get; set; } = new();
protected override async Task OnInitializedAsync()
{
if (messageId is { Length: 0 })
{
Navigation.NavigateTo("/");
return;
}
var currentMessage = await DbStorage.GetMessage(messageId);
var messages = await DbStorage.GetMessages();
if (currentMessage.RootMessageId is { Length: > 0 })
Messages = messages.Where(m => m.RootMessageId == currentMessage.RootMessageId)
.OrderByDescending(m => m.CreatedAt)
.ToList();
else
Messages = messages.Where(m => m.RootMessageId == messageId)
.OrderByDescending(m => m.CreatedAt)
.ToList();
}
}