@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Auth
@using ImageBoardServerApp.Data
@using ImageBoardServerApp.Data.Repository
@inject AuthenticationStateProvider authStateProvider
@if (opened)
{
@if (@post.Image != null)
{
}
else
{
[No Image]
}
@foreach (string s in @post.Content.Split("\n"))
{
@if (@s.StartsWith(">"))
{
@s
}
else
{
@s
}
}
}
@code {
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 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 || post.UserID == foundusr.UserID)
{
await PostsRepository.deletePostAsync(post.PostID);
}
}
private bool opened = true;
private string toggleText = "-";
private void ToggleOpened()
{
opened = !opened;
toggleText = opened ? "-" : "+";
}
[Parameter]
[Required]
public PostData post { get; set; }
[Parameter]
[Required]
public bool showOpenThread { get; set; }
}