mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(board nav): if in catalog view, navigate to select sub's catalog view
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Subplebbit } from '@plebbit/plebbit-react-hooks';
|
import { Subplebbit } from '@plebbit/plebbit-react-hooks';
|
||||||
|
import { isCatalogView } from '../../lib/utils/view-utils';
|
||||||
import styles from './board-nav.module.css';
|
import styles from './board-nav.module.css';
|
||||||
|
|
||||||
interface BoardNavProps {
|
interface BoardNavProps {
|
||||||
@@ -10,6 +11,7 @@ interface BoardNavProps {
|
|||||||
|
|
||||||
const BoardNavDesktop = ({ subplebbits }: BoardNavProps) => {
|
const BoardNavDesktop = ({ subplebbits }: BoardNavProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const isInCatalogView = isCatalogView(useLocation().pathname, useParams());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.boardNavDesktop}>
|
<div className={styles.boardNavDesktop}>
|
||||||
@@ -21,7 +23,7 @@ const BoardNavDesktop = ({ subplebbits }: BoardNavProps) => {
|
|||||||
return (
|
return (
|
||||||
<span key={index}>
|
<span key={index}>
|
||||||
{index === 0 ? null : ' '}
|
{index === 0 ? null : ' '}
|
||||||
<Link to={`/p/${address}`} title={title || ''}>
|
<Link to={`/p/${address}${isInCatalogView && '/catalog'}`} title={title || ''}>
|
||||||
{address.includes('.') ? address : title || address.slice(0, 10).concat('...')}
|
{address.includes('.') ? address : title || address.slice(0, 10).concat('...')}
|
||||||
</Link>
|
</Link>
|
||||||
{index !== subplebbits.length - 1 ? ' /' : null}
|
{index !== subplebbits.length - 1 ? ' /' : null}
|
||||||
@@ -44,8 +46,10 @@ const BoardNavMobile = ({ subplebbits, currentSubplebbit }: BoardNavProps) => {
|
|||||||
|
|
||||||
const currentSubplebbitIsInList = subplebbits.some((subplebbit: any) => subplebbit?.address === currentSubplebbit);
|
const currentSubplebbitIsInList = subplebbits.some((subplebbit: any) => subplebbit?.address === currentSubplebbit);
|
||||||
|
|
||||||
|
const isInCatalogView = isCatalogView(useLocation().pathname, useParams());
|
||||||
|
|
||||||
const boardSelect = (
|
const boardSelect = (
|
||||||
<select value={currentSubplebbit || 'all'} onChange={(e) => navigate(`/p/${e.target.value}`)}>
|
<select value={currentSubplebbit || 'all'} onChange={(e) => navigate(`/p/${e.target.value}${isInCatalogView && '/catalog'}`)}>
|
||||||
{!currentSubplebbitIsInList && currentSubplebbit && <option value={currentSubplebbit}>{displaySubplebbitAddress}</option>}
|
{!currentSubplebbitIsInList && currentSubplebbit && <option value={currentSubplebbit}>{displaySubplebbitAddress}</option>}
|
||||||
<option value='all'>{t('all')}</option>
|
<option value='all'>{t('all')}</option>
|
||||||
<option value='subscriptions'>{t('subscriptions')}</option>
|
<option value='subscriptions'>{t('subscriptions')}</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user