From c5112e05bedada2de259aff5cb549dc95403bec6 Mon Sep 17 00:00:00 2001 From: Kentai Radiquum Date: Fri, 9 Aug 2024 14:55:42 +0500 Subject: [PATCH] feat: add spoiler/low rating warning for comment --- TODO.md | 1 - app/components/Comments/Comments.Comment.tsx | 43 +++++++++++++++++--- app/components/Comments/Comments.Main.tsx | 8 ++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index ed487de..2b2d645 100644 --- a/TODO.md +++ b/TODO.md @@ -33,7 +33,6 @@ - [ ] Просмотр комментариев и комментирование - [ ] Отправление комментариев - [ ] Отправление ответов - - [ ] Метка комментариев как спойлер - [ ] Видео тайтла [трейлеры, опенинги] (?) diff --git a/app/components/Comments/Comments.Comment.tsx b/app/components/Comments/Comments.Comment.tsx index 8b5428b..3261566 100644 --- a/app/components/Comments/Comments.Comment.tsx +++ b/app/components/Comments/Comments.Comment.tsx @@ -13,6 +13,10 @@ export const CommentsComment = (props: { reply_count: number; likes_count: number; vote: number; + isSpoiler: boolean; + isEdited: boolean; + isDeleted: boolean; + can_like: boolean; }; isSubComment?: boolean; token: string | null; @@ -20,6 +24,9 @@ export const CommentsComment = (props: { const [replies, setReplies] = useState([]); const [likes, setLikes] = useState(props.comment.likes_count); const [vote, setVote] = useState(props.comment.vote); + const [isHidden, setIsHidden] = useState( + props.comment.isSpoiler || props.comment.likes_count < -5 + ); useEffect(() => { async function _fetchReplies() { @@ -99,10 +106,33 @@ export const CommentsComment = (props: {

-

- {props.comment.message} -

-
+
+

+ {!props.comment.isDeleted + ? props.comment.message + : "Комментарий был удалён."} +

+ {isHidden && ( + + )} +
+