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
+14 -11
View File
@@ -63,24 +63,29 @@ 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 && (
<>
[
{subplebbits.map((sub: any, index: any) => (
<span key={index}> <span key={index}>
{index === 0 ? null : ' '} {index === 0 ? null : ' '}
<Link to={`/p/${sub.address}${isInCatalogView ? '/catalog' : ''}`}>{sub.address.includes('.') ? sub.address : sub.address.slice(0, 10).concat('...')}</Link> <Link to={`/p/${sub.address}${isInCatalogView ? '/catalog' : ''}`}>{sub.address.includes('.') ? sub.address : sub.address.slice(0, 10).concat('...')}</Link>
{index !== subplebbits.length - 1 ? ' /' : null} {index !== subplebbits.length - 1 ? ' /' : null}
</span> </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) => {
@@ -101,8 +106,6 @@ const TopBarDesktop = () => {
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>] [