2023-01-25 22:45:36 +00:00
|
|
|
@using System.ComponentModel.DataAnnotations
|
2023-02-03 10:33:56 +00:00
|
|
|
@using ImageBoardServerApp.Auth
|
2023-01-25 22:45:36 +00:00
|
|
|
@using ImageBoardServerApp.Data
|
2023-01-26 12:04:55 +00:00
|
|
|
@using ImageBoardServerApp.Data.Repository
|
2023-02-03 10:33:56 +00:00
|
|
|
@inject AuthenticationStateProvider authStateProvider
|
2023-01-25 22:45:36 +00:00
|
|
|
|
|
|
|
<div class="threadHeader">
|
|
|
|
<span>[</span>
|
|
|
|
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
|
|
|
<span>]</span>
|
|
|
|
<span class="name">@comment.Username</span>
|
2023-02-13 17:45:14 +00:00
|
|
|
@if (@role != "User")
|
2023-02-07 20:21:38 +00:00
|
|
|
{
|
2023-02-13 17:45:14 +00:00
|
|
|
<span class="@role" >##@role</span>
|
2023-02-07 20:21:38 +00:00
|
|
|
}
|
2023-01-25 22:45:36 +00:00
|
|
|
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
|
|
|
<span class="post-id">No.@comment.CommentID</span>
|
|
|
|
</div>
|
|
|
|
@if (opened)
|
|
|
|
{
|
|
|
|
<div class="threadContent">
|
|
|
|
<div class="threadImage">
|
2023-01-26 12:04:55 +00:00
|
|
|
@if (image != null)
|
2023-01-25 22:45:36 +00:00
|
|
|
{
|
2023-02-01 13:18:36 +00:00
|
|
|
<img src="@($"{image.ImageLocation}")" alt="No Image found" />
|
2023-01-25 22:45:36 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div class="threadTextContainer">
|
|
|
|
@foreach (string s in @comment.Content.Split("\n"))
|
|
|
|
{
|
2023-01-26 12:04:55 +00:00
|
|
|
@if (s.StartsWith(">"))
|
|
|
|
{
|
|
|
|
<span class="threadText greenText">@s</span>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span class='threadText'>@s</span>
|
|
|
|
}
|
2023-01-25 22:45:36 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="threadFooter">
|
|
|
|
<span>[</span>
|
2023-02-03 10:33:56 +00:00
|
|
|
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
|
|
|
<span>]</span>
|
|
|
|
<span>[</span>
|
2023-02-12 16:01:46 +00:00
|
|
|
<a class="report" href="/sys/report/comment/@comment.Board/@comment.CommentID" target="_blank">Report</a>
|
2023-01-25 22:45:36 +00:00
|
|
|
<span>]</span>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code {
|
2023-02-03 10:33:56 +00:00
|
|
|
|
|
|
|
private async Task deletePost()
|
|
|
|
{
|
|
|
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
|
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
|
|
var usr = user.User;
|
|
|
|
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
|
|
|
if (foundusr.PermissionInteger >= 50 || comment.UserID == foundusr.UserID)
|
|
|
|
{
|
2023-02-13 17:45:14 +00:00
|
|
|
await TheManager.deleteComment(comment);
|
2023-02-03 10:33:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-25 22:45:36 +00:00
|
|
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
|
|
|
{
|
|
|
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
|
|
|
|
return dateTime;
|
|
|
|
}
|
2023-01-26 12:04:55 +00:00
|
|
|
|
|
|
|
private ImageData image;
|
2023-02-13 17:45:14 +00:00
|
|
|
private string role;
|
2023-01-26 12:04:55 +00:00
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
i = (int)comment.ImageID;
|
|
|
|
}
|
|
|
|
catch (InvalidOperationException ioe)
|
|
|
|
{
|
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
if (i != null)
|
|
|
|
{
|
|
|
|
image = await ImagesRepository.getImageByIdAsync(i);
|
|
|
|
}
|
2023-02-13 17:45:14 +00:00
|
|
|
|
|
|
|
var cmt = await CommentsRepository.getCommentByIdAsync(comment.CommentID);
|
|
|
|
role = cmt.User.Role;
|
2023-01-26 12:04:55 +00:00
|
|
|
}
|
2023-01-25 22:45:36 +00:00
|
|
|
|
|
|
|
private bool opened = true;
|
|
|
|
|
|
|
|
private string toggleText = "-";
|
|
|
|
|
|
|
|
private void ToggleOpened()
|
|
|
|
{
|
|
|
|
opened = !opened;
|
|
|
|
toggleText = opened ? "-" : "+";
|
|
|
|
}
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public CommentData comment { get; set; }
|
|
|
|
}
|