fix: Page no longer Errors when accessing a nonexistent thread

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-13 07:42:48 +02:00
parent 2fa9ca826e
commit 508510962a

View file

@ -19,30 +19,30 @@
</div>
@code {
[Parameter]
[Required]
public string boardName { get; set; }
[Parameter]
[Required]
public string threadId { get; set; }
private PostData post;
protected override async Task OnInitializedAsync()
{
try
{
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
}
catch (FormatException fe)
{
if (!int.TryParse(threadId, out _))
NavigationManager.NavigateTo("/notfound");
return;
}
if(post.Board != boardName)
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
if (post == null)
NavigationManager.NavigateTo("/notfound");
if(post == null)
if (post.Board != boardName)
NavigationManager.NavigateTo("/notfound");
if (post == null)
NavigationManager.NavigateTo("/notfound");
}
}