feat: finished implementing replying
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
396edeefde
commit
d2657d28b4
1 changed files with 89 additions and 10 deletions
|
@ -1,8 +1,7 @@
|
||||||
@using System.ComponentModel.DataAnnotations
|
|
||||||
@using System.Text.RegularExpressions
|
@using System.Text.RegularExpressions
|
||||||
@using ImageBoardServerApp.Auth
|
@using ImageBoardServerApp.Auth
|
||||||
@using ImageBoardServerApp.Data
|
|
||||||
@using ImageBoardServerApp.Data.Repository
|
@using ImageBoardServerApp.Data.Repository
|
||||||
|
@using System.ComponentModel.DataAnnotations
|
||||||
@inject AuthenticationStateProvider authStateProvider
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
|
|
||||||
<div class="threadHeader">
|
<div class="threadHeader">
|
||||||
|
@ -23,28 +22,52 @@
|
||||||
<div class="threadImage">
|
<div class="threadImage">
|
||||||
@if (image != null)
|
@if (image != null)
|
||||||
{
|
{
|
||||||
<img src="@($"{image.ImageLocation}?size=258x258")" alt="No Image found" />
|
string isActiveClass = isActive ? "active" : "";
|
||||||
|
<img @onclick="() => isActive = !isActive" class="@isActiveClass" src="@($"{@image.ImageLocation}?size=258x258")" alt="No Image found" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="threadTextContainer">
|
<div class="threadTextContainer">
|
||||||
@foreach (string s in @comment.Content.Split("\n"))
|
@for (var y = 0; y < comment.Content.Split("\n").Length; y++)
|
||||||
{
|
{
|
||||||
|
var s = comment.Content.Split("\n")[y];
|
||||||
var className = "";
|
var className = "";
|
||||||
|
|
||||||
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
||||||
{
|
{
|
||||||
className = "greenText";
|
className = "greenText";
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='threadText @className'>
|
<span class='threadText @className'>
|
||||||
@foreach (string line in s.Split(" "))
|
@for (var x = 0; x < s.Split(" ").Length; x++)
|
||||||
{
|
{
|
||||||
var className2 = "";
|
var line = s.Split(" ")[x];
|
||||||
@if (@Regex.IsMatch(line, ">>\\d+"))
|
@if (@Regex.IsMatch(line, ">>\\d+"))
|
||||||
{
|
{
|
||||||
|
var className2 = "";
|
||||||
|
var x1 = x;
|
||||||
|
var y1 = y;
|
||||||
|
var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2));
|
||||||
className2 = "redText";
|
className2 = "redText";
|
||||||
<a href="/@comment.Board/@comment.PostID/@Regex.Match(s, ">>(\\d+)").Value.Substring(2)" class="threadMsg @className2">
|
<span
|
||||||
|
@onmouseenter="() => onHover(x1, y1, commentNumber)"
|
||||||
|
@onmouseleave="() => onHover(x1, y1, -1)" class="threadMsg @className2"
|
||||||
|
>
|
||||||
@line
|
@line
|
||||||
</a>
|
</span>
|
||||||
|
@if (hoveringOver.p != -1 && hoveringOver == (x, y, commentNumber))
|
||||||
|
{
|
||||||
|
@if (isComment[commentNumber])
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
<CommentHover comment="hoverComment[commentNumber]"/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
<Post post="hoverPost[commentNumber]" showOpenThread="false"/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -73,6 +96,19 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
|
private bool isActive { get; set; } = false;
|
||||||
|
|
||||||
|
private (int x, int y, int p) hoveringOver { get; set; } = (-1, -1, -1);
|
||||||
|
private Dictionary<int, bool> isComment{ get; set; }
|
||||||
|
private Dictionary<int, CommentData> hoverComment { get; set; }
|
||||||
|
private Dictionary<int, PostData> hoverPost { get; set; }
|
||||||
|
private Dictionary<int, int> nrToGet { get; set; }
|
||||||
|
|
||||||
|
private void onHover(int x, int y, int p)
|
||||||
|
{
|
||||||
|
hoveringOver = (x, y, p);
|
||||||
|
}
|
||||||
|
|
||||||
public bool canDel { get; set; }
|
public bool canDel { get; set; }
|
||||||
|
|
||||||
private async Task deletePost()
|
private async Task deletePost()
|
||||||
|
@ -110,6 +146,41 @@
|
||||||
canDel = true;
|
canDel = true;
|
||||||
}
|
}
|
||||||
canDel = false;
|
canDel = false;
|
||||||
|
|
||||||
|
hoverComment = new Dictionary<int, CommentData>();
|
||||||
|
hoverPost = new Dictionary<int, PostData>();
|
||||||
|
nrToGet = new Dictionary<int, int>();
|
||||||
|
isComment = new Dictionary<int, bool>();
|
||||||
|
|
||||||
|
foreach (string s in comment.Content.Split("\n"))
|
||||||
|
{
|
||||||
|
@foreach (string line in s.Split(" "))
|
||||||
|
{
|
||||||
|
@if (Regex.IsMatch(line, ">>\\d+"))
|
||||||
|
{
|
||||||
|
var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2));
|
||||||
|
string board = comment.Board;
|
||||||
|
if (await TheManager.isGETComment(board, commentNumber))
|
||||||
|
{
|
||||||
|
CommentData c = await CommentsRepository.getCommentByGETAsync(board, commentNumber);
|
||||||
|
if (c == null)
|
||||||
|
continue;
|
||||||
|
hoverComment[commentNumber] = c;
|
||||||
|
nrToGet[commentNumber] = c.GET;
|
||||||
|
isComment[commentNumber] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PostData p = await PostsRepository.getPostByGETAsync(board, commentNumber);
|
||||||
|
if (p == null)
|
||||||
|
continue;
|
||||||
|
hoverPost[commentNumber] = p;
|
||||||
|
nrToGet[commentNumber] = p.GET;
|
||||||
|
isComment[commentNumber] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
@ -142,6 +213,14 @@
|
||||||
toggleText = opened ? "-" : "+";
|
toggleText = opened ? "-" : "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string toggleText2 = "-";
|
||||||
|
private bool showHover = false;
|
||||||
|
private void ToggleHovered(MouseEventArgs e, string id)
|
||||||
|
{
|
||||||
|
showHover = !showHover;
|
||||||
|
toggleText2 = showHover ? "-" : "+";
|
||||||
|
}
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public CommentData comment { get; set; }
|
public CommentData comment { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue