mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
show failed label only for failed state
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React
|
||||||
|
// , { useState, useEffect }
|
||||||
|
from "react";
|
||||||
import { useAccountComment } from "@plebbit/plebbit-react-hooks";
|
import { useAccountComment } from "@plebbit/plebbit-react-hooks";
|
||||||
import useStateString from "../hooks/useStateString";
|
// import useStateString from "../hooks/useStateString";
|
||||||
|
|
||||||
const PendingLabel = ({ commentIndex }) => {
|
const PendingLabel = ({ commentIndex }) => {
|
||||||
const comment = useAccountComment({commentIndex: commentIndex});
|
const comment = useAccountComment({commentIndex: commentIndex});
|
||||||
const stateString = useStateString(comment);
|
// const stateString = useStateString(comment);
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
// const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const timer = setTimeout(() => setIsLoading(false), 2000);
|
// const timer = setTimeout(() => setIsLoading(false), 2000);
|
||||||
return () => clearTimeout(timer);
|
// return () => clearTimeout(timer);
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
if (commentIndex === undefined) return null;
|
if (commentIndex === undefined) return null;
|
||||||
|
|
||||||
@@ -19,7 +21,9 @@ const PendingLabel = ({ commentIndex }) => {
|
|||||||
comment.cid ? (
|
comment.cid ? (
|
||||||
<span>{comment.cid.slice(2, 14)}</span>
|
<span>{comment.cid.slice(2, 14)}</span>
|
||||||
) : (
|
) : (
|
||||||
(comment.state === "failed" || (stateString === undefined && !isLoading)) ? (
|
(comment.state === "failed"
|
||||||
|
// || (stateString === undefined && !isLoading)
|
||||||
|
) ? (
|
||||||
<span style={{color: 'red', fontWeight: '700'}}>
|
<span style={{color: 'red', fontWeight: '700'}}>
|
||||||
Failed
|
Failed
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -17,16 +17,18 @@ const StateLabel = ({ commentIndex, className }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
commentIndex && stateString !== "Succeeded" ? (
|
commentIndex && stateString !== "Succeeded" ? (
|
||||||
(comment.state === "failed" || (stateString === undefined && !isLoading && comment.cid === undefined)) ? (
|
(comment.state === "failed") ? (
|
||||||
<span className="ttl">
|
null
|
||||||
<br />
|
|
||||||
(
|
|
||||||
<span className="ttl">
|
|
||||||
Failed
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
) : (
|
) : (
|
||||||
|
stateString === undefined && !isLoading && comment.cid === undefined ? (
|
||||||
|
<span className="ttl">
|
||||||
|
<br />
|
||||||
|
(
|
||||||
|
<span className={className}>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
<span className="ttl">
|
<span className="ttl">
|
||||||
<br />
|
<br />
|
||||||
(
|
(
|
||||||
@@ -35,7 +37,7 @@ const StateLabel = ({ commentIndex, className }) => {
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
</span>
|
</span>
|
||||||
)
|
))
|
||||||
) : null
|
) : null
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user