@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Auth
@using ImageBoardServerApp.Data
@using ImageBoardServerApp.Data.Repository
@inject AuthenticationStateProvider authStateProvider
@if (opened)
{
@if (image != null)
{
}
@foreach (string s in @comment.Content.Split("\n"))
{
@if (s.StartsWith(">"))
{
@s
}
else
{
@s
}
}
}
@code {
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)
{
await TheManager.deleteComment(comment);
}
}
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;
}
private ImageData image;
private string role;
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);
}
var cmt = await CommentsRepository.getCommentByIdAsync(comment.CommentID);
role = cmt.User.Role;
}
private bool opened = true;
private string toggleText = "-";
private void ToggleOpened()
{
opened = !opened;
toggleText = opened ? "-" : "+";
}
[Parameter]
[Required]
public CommentData comment { get; set; }
}