diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor b/ImageBoardServerApp/Shared/Components/Comment.razor
index 41df06a..f258759 100644
--- a/ImageBoardServerApp/Shared/Components/Comment.razor
+++ b/ImageBoardServerApp/Shared/Components/Comment.razor
@@ -10,10 +10,11 @@
@toggleText
]
@comment.Username
- @if (@role != "User")
+ @if (@role != "User" && !comment.shouldAnon)
{
##@role
}
+
@getTimeFromUnix(comment.CreatedAt)
No.@comment.GET
@@ -149,7 +150,6 @@
{
await base.OnParametersSetAsync();
-
hoverComment = new Dictionary();
hoverPost = new Dictionary();
nrToGet = new Dictionary();
@@ -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;
diff --git a/ImageBoardServerApp/Shared/Components/CommentHover.razor b/ImageBoardServerApp/Shared/Components/CommentHover.razor
index 626d70a..eb4a254 100644
--- a/ImageBoardServerApp/Shared/Components/CommentHover.razor
+++ b/ImageBoardServerApp/Shared/Components/CommentHover.razor
@@ -4,13 +4,13 @@
@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
};
}
diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
index a0b7960..fd3af29 100644
--- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
+++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
@@ -28,6 +28,12 @@
+
+
+
+
+
+
@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)
diff --git a/ImageBoardServerApp/Shared/Components/Post.razor b/ImageBoardServerApp/Shared/Components/Post.razor
index f351583..1ac7a03 100644
--- a/ImageBoardServerApp/Shared/Components/Post.razor
+++ b/ImageBoardServerApp/Shared/Components/Post.razor
@@ -17,11 +17,11 @@
}
@post.Title
@post.Username
- @if (post.User.Role != "User")
+ @if (post.User.Role != "User" && !post.shouldAnon)
{
- ##@post.User.Role
+ ##@post.User.Role
}
-
+
@getTimeFromUnix(post.CreatedAt)
No.@post.GET
@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);
+ var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
+ var user = await cauthStateProvder.GetAuthenticationStateAsync();
+ 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();
}