Files
5chan/src/components/StateLabel.jsx
T

29 lines
697 B
React
Raw Normal View History

2023-09-16 21:40:23 +02:00
import React from 'react';
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
import useStateString from '../hooks/useStateString';
2023-06-01 10:43:17 +02:00
const StateLabel = ({ commentIndex, className }) => {
2023-09-23 10:30:48 +02:00
const comment = useAccountComment({ commentIndex: commentIndex });
const stateString = useStateString(comment);
2023-06-01 10:43:17 +02:00
2023-09-23 10:30:48 +02:00
if (comment.updatedAt !== undefined || comment.index === undefined) {
return null;
}
2023-09-23 10:30:48 +02:00
if (comment.state === 'failed' || comment.state === 'succeeded') {
return null;
}
2023-08-18 20:46:32 +02:00
2023-09-23 10:30:48 +02:00
if (!stateString) {
return null;
}
2023-09-23 10:30:48 +02:00
return (
<span className='ttl'>
<br />(<span className={className}>{stateString}</span>)
</span>
);
2023-06-01 10:43:17 +02:00
};
2023-09-16 21:40:23 +02:00
export default StateLabel;