fix: Page no longer Errors when accessing a nonexistent thread
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
2fa9ca826e
commit
508510962a
1 changed files with 12 additions and 12 deletions
|
@ -19,30 +19,30 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public string boardName { get; set; }
|
public string boardName { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public string threadId { get; set; }
|
public string threadId { get; set; }
|
||||||
|
|
||||||
private PostData post;
|
private PostData post;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
try
|
if (!int.TryParse(threadId, out _))
|
||||||
{
|
|
||||||
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
|
|
||||||
}
|
|
||||||
catch (FormatException fe)
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo("/notfound");
|
NavigationManager.NavigateTo("/notfound");
|
||||||
return;
|
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
|
||||||
}
|
|
||||||
if(post.Board != boardName)
|
if (post == null)
|
||||||
NavigationManager.NavigateTo("/notfound");
|
NavigationManager.NavigateTo("/notfound");
|
||||||
if(post == null)
|
|
||||||
|
if (post.Board != boardName)
|
||||||
|
NavigationManager.NavigateTo("/notfound");
|
||||||
|
if (post == null)
|
||||||
NavigationManager.NavigateTo("/notfound");
|
NavigationManager.NavigateTo("/notfound");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue