fix(topbar): empty brackets would show for sub category if empty

This commit is contained in:
Tom (plebeius.eth)
2024-07-10 17:42:38 +02:00
parent d66a0b8efe
commit a31beee631
+39 -36
View File
@@ -63,46 +63,49 @@ const TopBarDesktop = () => {
const { plebbitSubs, interestsSubs, randomSubs, internationalSubs, projectsSubs } = categorizeSubplebbits(subplebbits); const { plebbitSubs, interestsSubs, randomSubs, internationalSubs, projectsSubs } = categorizeSubplebbits(subplebbits);
const renderSubplebbits = (subplebbits: any) => { const renderSubplebbits = (subplebbits: any) =>
return subplebbits.map((sub: any, index: any) => ( subplebbits.length > 0 && (
<span key={index}> <>
{index === 0 ? null : ' '} [
<Link to={`/p/${sub.address}${isInCatalogView ? '/catalog' : ''}`}>{sub.address.includes('.') ? sub.address : sub.address.slice(0, 10).concat('...')}</Link> {subplebbits.map((sub: any, index: any) => (
{index !== subplebbits.length - 1 ? ' /' : null} <span key={index}>
</span> {index === 0 ? null : ' '}
)); <Link to={`/p/${sub.address}${isInCatalogView ? '/catalog' : ''}`}>{sub.address.includes('.') ? sub.address : sub.address.slice(0, 10).concat('...')}</Link>
}; {index !== subplebbits.length - 1 ? ' /' : null}
</span>
))}
]{' '}
</>
);
return ( return (
<div className={styles.boardNavDesktop}> <div className={styles.boardNavDesktop}>
<span className={styles.boardList}> <span className={styles.boardList}>
[<Link to='/p/all'>all</Link> / <Link to='/p/subscriptions'>subscriptions</Link>]{' '} [<Link to='/p/all'>all</Link> / <Link to='/p/subscriptions'>subscriptions</Link>] {renderSubplebbits(plebbitSubs)}
{subplebbits && ( {renderSubplebbits(projectsSubs)}
<> {renderSubplebbits(interestsSubs)}
[{renderSubplebbits(plebbitSubs)}] [{renderSubplebbits(projectsSubs)}] [{renderSubplebbits(interestsSubs)}] [{renderSubplebbits(randomSubs)}] [ {renderSubplebbits(randomSubs)}
{renderSubplebbits(internationalSubs)}] [ {renderSubplebbits(internationalSubs)}[
<Link <Link
to='boards/create' to='boards/create'
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
alert('work in progress'); alert('work in progress');
}} }}
> >
Create Create
</Link> </Link>
] [ ] [
<Link <Link
to='boards' to='boards'
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
alert('work in progress'); alert('work in progress');
}} }}
> >
Vote Vote
</Link> </Link>
] ]
</>
)}
</span> </span>
<span className={styles.navTopRight}> <span className={styles.navTopRight}>
[<Link to={!location.pathname.endsWith('settings') ? location.pathname.replace(/\/$/, '') + '/settings' : location.pathname}>{t('settings')}</Link>] [ [<Link to={!location.pathname.endsWith('settings') ? location.pathname.replace(/\/$/, '') + '/settings' : location.pathname}>{t('settings')}</Link>] [