feat: it is now possible to not show the admin tag when posting, fixed the delete button not showing up

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-13 08:51:53 +02:00
parent 9bb208d011
commit 9d733af389
5 changed files with 33 additions and 31 deletions

View file

@ -10,10 +10,11 @@
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
<span>]</span>
<span class="name">@comment.Username</span>
@if (@role != "User")
@if (@role != "User" && !comment.shouldAnon)
{
<span class="@role">##@role</span>
}
<span>&nbsp;</span>
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
<span class="post-id">No.@comment.GET</span>
</div>
@ -149,7 +150,6 @@
{
await base.OnParametersSetAsync();
hoverComment = new Dictionary<int, CommentData>();
hoverPost = new Dictionary<int, PostData>();
nrToGet = new Dictionary<int, int>();
@ -185,10 +185,6 @@
}
}
reportURL = $"/sys/report/comment/{comment.Board}/{comment.CommentID}";
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
var usr = user.User;
@ -201,9 +197,9 @@
{
canDel = false;
}
await base.OnAfterRenderAsync(firstRender);
}
protected override async Task OnInitializedAsync()
{
int i;

View file

@ -4,13 +4,13 @@
<div class="comment">
<span class="name">@comment.Username</span>
@if (@role != "User")
@if (@role != "User" && !comment.shouldAnon)
{
<span class="@role">##@role </span>
<span class="@role">##@role&nbsp;</span>
}
else
{
<span> </span>
<span>&nbsp;</span>
}
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
<span class="post-id">No.@comment.GET</span>

View file

@ -24,6 +24,12 @@
<div class="pd centered marg">
<RadzenTextArea Placeholder="Comment..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
</div>
<AuthorizeView Roles="Admin,Mod">
<Authorized>
<RadzenCheckBox @bind-Value=@postAnon Name="postAsAnon"/>
<RadzenLabel Text="Do not show role." Component="postAsAnon"/>
</Authorized>
</AuthorizeView>
</div>
</div>
@if (hasErr)
@ -57,6 +63,7 @@
string postUsername { get; set; }
string postContent { get; set; } = "";
bool postAnon { get; set; } = false;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@ -164,7 +171,8 @@
Username = postUsername,
Board = post.Board,
CreatedAt = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
GET = thisGET
GET = thisGET,
shouldAnon = postAnon
};
}
else
@ -177,7 +185,8 @@
Username = postUsername,
Board = post.Board,
CreatedAt = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
GET = thisGET
GET = thisGET,
shouldAnon = postAnon
};
}

View file

@ -28,6 +28,12 @@
<div class="pd centered marg">
<RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
</div>
<AuthorizeView Roles="Admin,Mod">
<Authorized>
<RadzenCheckBox @bind-Value=@postAnon Name="postAsAnon"/>
<RadzenLabel Text="Do not show role." Component="postAsAnon"/>
</Authorized>
</AuthorizeView>
</div>
</div>
@if (hasErr)
@ -63,6 +69,7 @@
string postUsername { get; set; }
string postTitle { get; set; } = "";
string postContent { get; set; } = "";
bool postAnon { get; set; } = false;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@ -175,7 +182,8 @@
Board = board.Tag,
IsLocked = false,
IsSticky = false,
GET = thisGET
GET = thisGET,
shouldAnon = postAnon
};
int postId = await PostsRepository.createPostAsync(postToPost);
if (postId != -1)

View file

@ -17,11 +17,11 @@
}
<span class="title">@post.Title</span>
<span class="name">@post.Username </span>
@if (post.User.Role != "User")
@if (post.User.Role != "User" && !post.shouldAnon)
{
<span class="@post.User.Role">##@post.User.Role </span>
<span class="@post.User.Role">##@post.User.Role&nbsp;</span>
}
<span> </span>
<span>&nbsp;</span>
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
<span class="post-id">No.@post.GET</span>
@if (post.IsSticky)
@ -202,8 +202,6 @@
toggleText = opened ? "-" : "+";
}
private int usrid { get; set; }
protected override async Task OnInitializedAsync()
{
value = TheManager.getBumpValue(post) + "v";
@ -212,25 +210,16 @@
threadURL = $"/{post.Board}/thread/{post.PostID}";
openThreadName = $"({post.Comments.Count}) View Thread";
await base.OnInitializedAsync();
}
public override async Task SetParametersAsync(ParameterView parameters)
{
if (usrid == null)
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
usrid = int.Parse(user.User.Identity.Name);
}
UserData foundusr = await UsersRepository.getUserByIdAsync(usrid);
UserData foundusr = await UsersRepository.getUserByEmailRawAsync(user.User.Identity.Name);
if (foundusr != null && (foundusr.Role != "User" || post.UserID == foundusr.UserID))
{
canDel = true;
return;
}
canDel = false;
await base.SetParametersAsync(parameters);
await base.OnInitializedAsync();
}