mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-19 16:04:41 +00:00
fix?: error if failed to get comment replies
This commit is contained in:
parent
ed96dd301c
commit
9d92c884e8
1 changed files with 27 additions and 23 deletions
|
@ -84,9 +84,17 @@ export const CommentsComment = (props: {
|
||||||
url += `&token=${props.token}`;
|
url += `&token=${props.token}`;
|
||||||
}
|
}
|
||||||
await fetch(url)
|
await fetch(url)
|
||||||
.then((res) => res.json())
|
.then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return res.json();
|
||||||
|
} else {
|
||||||
|
return { content: [] };
|
||||||
|
}
|
||||||
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
setReplies(data.content);
|
if (data && data.content) {
|
||||||
|
setReplies(data.content);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -194,9 +202,9 @@ export const CommentsComment = (props: {
|
||||||
</footer>
|
</footer>
|
||||||
<div className="relative flex items-center py-2">
|
<div className="relative flex items-center py-2">
|
||||||
<p className="text-gray-800 whitespace-pre-wrap dark:text-gray-400">
|
<p className="text-gray-800 whitespace-pre-wrap dark:text-gray-400">
|
||||||
{!props.comment.isDeleted
|
{!props.comment.isDeleted ?
|
||||||
? props.comment.message
|
props.comment.message
|
||||||
: "Комментарий был удалён."}
|
: "Комментарий был удалён."}
|
||||||
</p>
|
</p>
|
||||||
{isHidden && (
|
{isHidden && (
|
||||||
<button
|
<button
|
||||||
|
@ -205,9 +213,9 @@ export const CommentsComment = (props: {
|
||||||
>
|
>
|
||||||
<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">
|
<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>
|
<p>
|
||||||
{props.comment.likes_count < -5
|
{props.comment.likes_count < -5 ?
|
||||||
? "У комментария слишком низкий рейтинг."
|
"У комментария слишком низкий рейтинг."
|
||||||
: "Данный комментарий может содержать спойлер."}
|
: "Данный комментарий может содержать спойлер."}
|
||||||
</p>
|
</p>
|
||||||
<p className="font-bold">Нажмите, чтобы прочитать</p>
|
<p className="font-bold">Нажмите, чтобы прочитать</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -220,7 +228,7 @@ export const CommentsComment = (props: {
|
||||||
isHidden ? "mt-4" : ""
|
isHidden ? "mt-4" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{props.token ? (
|
{props.token ?
|
||||||
<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"
|
||||||
|
@ -243,9 +251,7 @@ export const CommentsComment = (props: {
|
||||||
</svg>
|
</svg>
|
||||||
Ответить
|
Ответить
|
||||||
</button>
|
</button>
|
||||||
) : (
|
: <span></span>}
|
||||||
<span></span>
|
|
||||||
)}
|
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<Button
|
<Button
|
||||||
color="inline"
|
color="inline"
|
||||||
|
@ -256,19 +262,17 @@ export const CommentsComment = (props: {
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={`w-6 h-6 iconify mdi--dislike ${
|
className={`w-6 h-6 iconify mdi--dislike ${
|
||||||
vote == 1
|
vote == 1 ?
|
||||||
? "text-red-500 dark:text-red-400"
|
"text-red-500 dark:text-red-400"
|
||||||
: "text-gray-500 dark:text-gray-400"
|
: "text-gray-500 dark:text-gray-400"
|
||||||
}`}
|
}`}
|
||||||
></span>
|
></span>
|
||||||
</Button>
|
</Button>
|
||||||
<p
|
<p
|
||||||
className={`text-sm font-medium ${
|
className={`text-sm font-medium ${
|
||||||
likes > 0
|
likes > 0 ? "text-green-500 dark:text-green-400"
|
||||||
? "text-green-500 dark:text-green-400"
|
: likes < 0 ? "text-red-500 dark:text-red-400"
|
||||||
: likes < 0
|
: "text-gray-500 dark:text-gray-400"
|
||||||
? "text-red-500 dark:text-red-400"
|
|
||||||
: "text-gray-500 dark:text-gray-400"
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{likes}
|
{likes}
|
||||||
|
@ -282,9 +286,9 @@ export const CommentsComment = (props: {
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={`w-6 h-6 iconify mdi--like ${
|
className={`w-6 h-6 iconify mdi--like ${
|
||||||
vote == 2
|
vote == 2 ?
|
||||||
? "text-green-500 dark:text-green-400"
|
"text-green-500 dark:text-green-400"
|
||||||
: "text-gray-500 dark:text-gray-400"
|
: "text-gray-500 dark:text-gray-400"
|
||||||
}`}
|
}`}
|
||||||
></span>
|
></span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue