From 9bdad9e48db0fb4357a45af6e6321a387e42e0ea Mon Sep 17 00:00:00 2001 From: limited_dev Date: Sat, 11 Mar 2023 00:56:51 +0100 Subject: [PATCH] chore: add README.md fix: added more space to the title, added delete button show up fix --- ImageBoardServerApp/Pages/_Host.cshtml | 2 +- .../Shared/Components/Comment.razor | 18 +++++++++++- .../Shared/Components/Forms/PostForm.razor | 2 +- .../Shared/Components/Post.razor | 28 +++++++++++++++---- ImageBoardServerApp/Shared/NavMenu.razor | 2 +- README.md | 5 ++++ 6 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 README.md diff --git a/ImageBoardServerApp/Pages/_Host.cshtml b/ImageBoardServerApp/Pages/_Host.cshtml index 630ed2f..4b19541 100644 --- a/ImageBoardServerApp/Pages/_Host.cshtml +++ b/ImageBoardServerApp/Pages/_Host.cshtml @@ -3,7 +3,6 @@ @namespace ImageBoardServerApp.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - @@ -16,6 +15,7 @@ + diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor b/ImageBoardServerApp/Shared/Components/Comment.razor index dbe28c1..5ca4456 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor +++ b/ImageBoardServerApp/Shared/Components/Comment.razor @@ -73,6 +73,8 @@ @code { + public bool canDel { get; set; } + private async Task deletePost() { var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; @@ -95,7 +97,21 @@ private ImageData image; private string role; - + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await base.OnAfterRenderAsync(firstRender); + var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; + var user = await cauthStateProvder.GetAuthenticationStateAsync(); + var usr = user.User; + UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); + if (foundusr != null && (foundusr.Role != "User" || comment.UserID == foundusr.UserID)) + { + canDel = true; + } + canDel = false; + } + protected override async Task OnInitializedAsync() { int i; diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor index 4e2fa9d..a3da72c 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor @@ -28,7 +28,7 @@
- +
diff --git a/ImageBoardServerApp/Shared/Components/Post.razor b/ImageBoardServerApp/Shared/Components/Post.razor index 5aa82ea..bebc901 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor +++ b/ImageBoardServerApp/Shared/Components/Post.razor @@ -93,10 +93,12 @@ ] - - [ - Delete - ] + @if (canDel) + { + [ + Delete + ] + } [ Report ] @@ -118,6 +120,8 @@ @code { + + public bool canDel { get; set; } private async void lockMe() { @@ -137,7 +141,7 @@ dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime(); return dateTime; } - + private async Task deletePost() { string boardTag = post.Board; @@ -165,9 +169,21 @@ toggleText = opened ? "-" : "+"; } - protected override async Task OnInitializedAsync() + protected override async Task OnAfterRenderAsync(bool firstRender) { + await base.OnAfterRenderAsync(firstRender); value = TheManager.getBumpValue(post) + "v"; + string boardTag = post.Board; + var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; + var user = await cauthStateProvder.GetAuthenticationStateAsync(); + var usr = user.User; + UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); + if (foundusr != null && (foundusr.Role != "User" || post.UserID == foundusr.UserID)) + { + canDel = true; + return; + } + canDel = false; } [Parameter] diff --git a/ImageBoardServerApp/Shared/NavMenu.razor b/ImageBoardServerApp/Shared/NavMenu.razor index 81cabe2..cd5b10b 100644 --- a/ImageBoardServerApp/Shared/NavMenu.razor +++ b/ImageBoardServerApp/Shared/NavMenu.razor @@ -5,7 +5,7 @@