From d44fb89b033b7a78160673caf4d5cedff1be549a Mon Sep 17 00:00:00 2001 From: koko <68549366+sudokoko@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:42:59 -0500 Subject: [PATCH 1/2] Fix comments not being disabled if banned --- .../Pages/Partials/CommentsPartial.cshtml | 109 +++++++++--------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml index 349ee6b5..80182239 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml @@ -1,4 +1,4 @@ -@using System.Web +@using System.Web @using System.IO @using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.PlayerData.Profiles @@ -36,7 +36,7 @@

There @(count == 1 ? "is" : "are") @count comment@(count == 1 ? "" : "s").

} - @if (Model.CommentsEnabled && Model.User != null) + @if (!Model.ProfileUser.IsBanned && Model.CommentsEnabled && Model.User != null) {
@@ -51,64 +51,67 @@ } } - @for(int i = 0; i < Model.Comments.Count; i++) + @if (!Model.ProfileUser.IsBanned) { - Comment comment = Model.Comments[i]; - DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000).ToLocalTime(); - StringWriter messageWriter = new(); - HttpUtility.HtmlDecode(comment.getComment(), messageWriter); + @for(int i = 0; i < Model.Comments.Count; i++) + { + Comment comment = Model.Comments[i]; + DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000).ToLocalTime(); + StringWriter messageWriter = new(); + HttpUtility.HtmlDecode(comment.getComment(), messageWriter); - string decodedMessage = messageWriter.ToString(); - string? url = Url.RouteUrl(ViewContext.RouteData.Values); - if (url == null) continue; + string decodedMessage = messageWriter.ToString(); + string? url = Url.RouteUrl(ViewContext.RouteData.Values); + if (url == null) continue; - int rating = comment.ThumbsUp - comment.ThumbsDown; + int rating = comment.ThumbsUp - comment.ThumbsDown; -
- @{ - string style = ""; - if (Model.User?.UserId == comment.PosterUserId) - { - style = "pointer-events: none"; +
+ @{ + string style = ""; + if (Model.User?.UserId == comment.PosterUserId) + { + style = "pointer-events: none"; + } } - } -
- - - - @(rating) - - - -
+
+ + + + @(rating) + + + +
-
- @await comment.Poster.ToLink(Html, ViewData, language): - @if (comment.Deleted) - { - +
+ @await comment.Poster.ToLink(Html, ViewData, language): + @if (comment.Deleted) + { + + @decodedMessage + + } + else + { @decodedMessage - - } - else - { - @decodedMessage - } - @if (((Model.User?.IsModerator ?? false) || Model.User?.UserId == comment.PosterUserId || Model.User?.UserId == pageOwnerId) && !comment.Deleted) - { - - } -

- @TimeZoneInfo.ConvertTime(timestamp, timeZoneInfo).ToString("M/d/yyyy @ h:mm:ss tt") -

- @if (i != Model.Comments.Count - 1) - { -
- } + } + @if (((Model.User?.IsModerator ?? false) || Model.User?.UserId == comment.PosterUserId || Model.User?.UserId == pageOwnerId) && !comment.Deleted) + { + + } +

+ @TimeZoneInfo.ConvertTime(timestamp, timeZoneInfo).ToString("M/d/yyyy @ h:mm:ss tt") +

+ @if (i != Model.Comments.Count - 1) + { +
+ } +
-
+ } } -
\ No newline at end of file + From d119bacd772a9a3374073ca87195d72c0819bc28 Mon Sep 17 00:00:00 2001 From: koko <68549366+sudokoko@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:58:30 -0500 Subject: [PATCH 2/2] Fix >50 comments message --- .../Pages/Partials/CommentsPartial.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml index 80182239..4c1a6c1d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/CommentsPartial.cshtml @@ -26,7 +26,7 @@ Comments are disabled. } - else if (Model.Comments.Count > 50) + else if (Model.Comments.Count >= 50) {

There are more than 50 comments. Displaying the newest ones.

}