mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-07 00:34:41 +00:00
feat: add spoiler/low rating warning for comment
This commit is contained in:
parent
e6271f20d9
commit
c5112e05be
3 changed files with 46 additions and 6 deletions
1
TODO.md
1
TODO.md
|
@ -33,7 +33,6 @@
|
||||||
- [ ] Просмотр комментариев и комментирование
|
- [ ] Просмотр комментариев и комментирование
|
||||||
- [ ] Отправление комментариев
|
- [ ] Отправление комментариев
|
||||||
- [ ] Отправление ответов
|
- [ ] Отправление ответов
|
||||||
- [ ] Метка комментариев как спойлер
|
|
||||||
|
|
||||||
- [ ] Видео тайтла [трейлеры, опенинги] (?)
|
- [ ] Видео тайтла [трейлеры, опенинги] (?)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,10 @@ export const CommentsComment = (props: {
|
||||||
reply_count: number;
|
reply_count: number;
|
||||||
likes_count: number;
|
likes_count: number;
|
||||||
vote: number;
|
vote: number;
|
||||||
|
isSpoiler: boolean;
|
||||||
|
isEdited: boolean;
|
||||||
|
isDeleted: boolean;
|
||||||
|
can_like: boolean;
|
||||||
};
|
};
|
||||||
isSubComment?: boolean;
|
isSubComment?: boolean;
|
||||||
token: string | null;
|
token: string | null;
|
||||||
|
@ -20,6 +24,9 @@ export const CommentsComment = (props: {
|
||||||
const [replies, setReplies] = useState([]);
|
const [replies, setReplies] = useState([]);
|
||||||
const [likes, setLikes] = useState(props.comment.likes_count);
|
const [likes, setLikes] = useState(props.comment.likes_count);
|
||||||
const [vote, setVote] = useState(props.comment.vote);
|
const [vote, setVote] = useState(props.comment.vote);
|
||||||
|
const [isHidden, setIsHidden] = useState(
|
||||||
|
props.comment.isSpoiler || props.comment.likes_count < -5
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function _fetchReplies() {
|
async function _fetchReplies() {
|
||||||
|
@ -99,10 +106,33 @@ export const CommentsComment = (props: {
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<p className="text-gray-500 whitespace-pre-wrap dark:text-gray-400">
|
<div className="relative flex items-center py-2">
|
||||||
{props.comment.message}
|
<p className="text-gray-500 whitespace-pre-wrap dark:text-gray-400">
|
||||||
</p>
|
{!props.comment.isDeleted
|
||||||
<div className="flex items-center justify-between mt-4 space-x-4">
|
? props.comment.message
|
||||||
|
: "Комментарий был удалён."}
|
||||||
|
</p>
|
||||||
|
{isHidden && (
|
||||||
|
<button
|
||||||
|
className="absolute top-0 bottom-0 left-0 right-0"
|
||||||
|
onClick={() => setIsHidden(false)}
|
||||||
|
>
|
||||||
|
<div className="min-w-full min-h-full px-2 py-1.5 rounded-md bg-black text-white bg-opacity-50 backdrop-blur-[8px] flex flex-col justify-center items-center">
|
||||||
|
<p>
|
||||||
|
{props.comment.likes_count < -5
|
||||||
|
? "У комментария слишком низкий рейтинг."
|
||||||
|
: "Данный комментарий может содержать спойлер."}
|
||||||
|
</p>
|
||||||
|
<p className="font-bold">Нажмите, чтобы прочитать</p>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={`flex items-center justify-between space-x-4 ${
|
||||||
|
isHidden ? "mt-4" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex items-center text-sm font-medium text-gray-500 hover:underline dark:text-gray-400"
|
className="flex items-center text-sm font-medium text-gray-500 hover:underline dark:text-gray-400"
|
||||||
|
@ -182,8 +212,11 @@ export const CommentsComment = (props: {
|
||||||
reply_count: comment.reply_count,
|
reply_count: comment.reply_count,
|
||||||
likes_count: comment.likes_count,
|
likes_count: comment.likes_count,
|
||||||
vote: comment.vote,
|
vote: comment.vote,
|
||||||
|
isSpoiler: comment.is_spoiler,
|
||||||
|
isEdited: comment.is_edited,
|
||||||
|
isDeleted: comment.is_deleted,
|
||||||
|
can_like: comment.can_like,
|
||||||
}}
|
}}
|
||||||
isSubComment={true}
|
|
||||||
token={props.token}
|
token={props.token}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -61,6 +61,10 @@ export const CommentsMain = (props: {
|
||||||
reply_count: comment.reply_count,
|
reply_count: comment.reply_count,
|
||||||
likes_count: comment.likes_count,
|
likes_count: comment.likes_count,
|
||||||
vote: comment.vote,
|
vote: comment.vote,
|
||||||
|
isSpoiler: comment.is_spoiler,
|
||||||
|
isEdited: comment.is_edited,
|
||||||
|
isDeleted: comment.is_deleted,
|
||||||
|
can_like: comment.can_like,
|
||||||
}}
|
}}
|
||||||
token={props.token}
|
token={props.token}
|
||||||
/>
|
/>
|
||||||
|
@ -181,6 +185,10 @@ const CommentsAllModal = (props: {
|
||||||
reply_count: comment.reply_count,
|
reply_count: comment.reply_count,
|
||||||
likes_count: comment.likes_count,
|
likes_count: comment.likes_count,
|
||||||
vote: comment.vote,
|
vote: comment.vote,
|
||||||
|
isSpoiler: comment.is_spoiler,
|
||||||
|
isEdited: comment.is_edited,
|
||||||
|
isDeleted: comment.is_deleted,
|
||||||
|
can_like: comment.can_like,
|
||||||
}}
|
}}
|
||||||
token={props.token}
|
token={props.token}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue