mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(board): show error in feed near loading string
This commit is contained in:
+3
-5
@@ -18,15 +18,13 @@ import SubplebbitStats from './components/subplebbit-stats';
|
|||||||
import TopBar from './components/topbar';
|
import TopBar from './components/topbar';
|
||||||
|
|
||||||
const BoardLayout = () => {
|
const BoardLayout = () => {
|
||||||
const { accountCommentIndex, commentCid, subplebbitAddress } = useParams();
|
const { accountCommentIndex, subplebbitAddress } = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0);
|
const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0);
|
||||||
const isValidCommentCid = !commentCid || /^Qm[a-zA-Z0-9]{44}$/.test(commentCid);
|
|
||||||
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3KooW[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
|
|
||||||
|
|
||||||
if (!isValidAccountCommentIndex || !isValidCommentCid || !isValidSubplebbitAddress) {
|
if (!isValidAccountCommentIndex) {
|
||||||
return <NotFound />;
|
return <NotFound />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +43,7 @@ const BoardLayout = () => {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<PostForm key={key} />
|
<PostForm key={key} />
|
||||||
{subplebbitAddress && isValidSubplebbitAddress && <SubplebbitStats />}
|
{subplebbitAddress && <SubplebbitStats />}
|
||||||
<DesktopBoardButtons />
|
<DesktopBoardButtons />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const Board = () => {
|
|||||||
setResetFunction(reset);
|
setResetFunction(reset);
|
||||||
}, [reset, setResetFunction]);
|
}, [reset, setResetFunction]);
|
||||||
|
|
||||||
const subplebbit = useSubplebbit({ subplebbitAddress });
|
const { subplebbit, error } = useSubplebbit({ subplebbitAddress });
|
||||||
const { createdAt, description, rules, shortAddress, state, suggested } = subplebbit || {};
|
const { createdAt, description, rules, shortAddress, state, suggested } = subplebbit || {};
|
||||||
const title = isInAllView ? t('all') : isInSubscriptionsView ? t('subscriptions') : subplebbit?.title;
|
const title = isInAllView ? t('all') : isInSubscriptionsView ? t('subscriptions') : subplebbit?.title;
|
||||||
|
|
||||||
@@ -65,6 +65,12 @@ const Board = () => {
|
|||||||
) : (
|
) : (
|
||||||
<LoadingEllipsis string={loadingStateString} />
|
<LoadingEllipsis string={loadingStateString} />
|
||||||
)}
|
)}
|
||||||
|
{error && (
|
||||||
|
<div style={{ color: 'red' }}>
|
||||||
|
<br />
|
||||||
|
{error.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user