added state message formatting

This commit is contained in:
plebbitor
2023-04-23 11:46:14 +02:00
parent 2760171d8b
commit 8e9708a442
5 changed files with 23 additions and 9 deletions
-1
View File
@@ -6,7 +6,6 @@ import useGeneralStore from '../hooks/stores/useGeneralStore';
import Modal from 'react-modal';
import Draggable from 'react-draggable';
import useError from '../hooks/useError';
import useSuccess from '../hooks/useSuccess';
const ReplyModal = ({ isOpen, closeModal }) => {
-1
View File
@@ -15,7 +15,6 @@ import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import handleStyleChange from '../../utils/handleStyleChange';
import useClickForm from '../../hooks/useClickForm';
import useError from '../../hooks/useError';
import useSuccess from '../../hooks/useSuccess';
const Catalog = () => {
+2 -5
View File
@@ -10,6 +10,7 @@ import ImageBanner from '../ImageBanner';
import Post from '../Post';
import PostLoader from '../PostLoader';
import SettingsModal from '../SettingsModal';
import formatState from '../../utils/formatState';
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import getDate from '../../utils/getDate';
import handleQuoteClick from '../../utils/handleQuoteClick';
@@ -166,11 +167,7 @@ const Pending = () => {
<Link to={`/p/${selectedAddress}/catalog`}>Catalog</Link>
]
</span>
{comment ? (
<span className="reply-stat">Preview</span>
) : (
<span className="reply-stat">Fetching IPFS...</span>
)}
<span className="reply-stat">{formatState(comment.state)}</span>
<hr />
</TopBar>
<Tooltip id="tooltip" className="tooltip" />
+3 -2
View File
@@ -13,6 +13,7 @@ import PostLoader from '../PostLoader';
import ReplyModal from '../ReplyModal';
import SettingsModal from '../SettingsModal';
import findShortParentCid from '../../utils/findShortParentCid';
import formatState from '../../utils/formatState';
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import getDate from '../../utils/getDate';
import handleAddressClick from '../../utils/handleAddressClick';
@@ -387,10 +388,10 @@ const Thread = () => {
<span className="reply-stat">No replies yet</span>
)
) : (
<span className="reply-stat">Fetching IPNS...</span>
<span className="reply-stat">{formatState(comment.state)}</span>
)
) : (
<span className="reply-stat">Fetching IPNS...</span>
<span className="reply-stat">{formatState(comment.state)}</span>
)}
<hr />
</TopBar>
+18
View File
@@ -0,0 +1,18 @@
function formatState(str) {
return (
str
.replace(/-/g, " ")
.split(" ")
.map((word) => {
word = word.toLowerCase();
if (word === "ipfs" || word === "ipns") {
return word.toUpperCase();
} else {
return word.charAt(0).toUpperCase() + word.slice(1);
}
})
.join(" ") + "..."
);
}
export default formatState;