This commit is contained in:
Tom (plebeius.eth)
2024-06-11 15:13:04 +02:00
parent 98539cecf6
commit 4435ff120b
3 changed files with 33 additions and 7 deletions
+29 -5
View File
@@ -17,10 +17,22 @@ interface BoardButtonsProps {
const CatalogButton = ({ address, isInAllView, isInSubscriptionsView }: BoardButtonsProps) => { const CatalogButton = ({ address, isInAllView, isInSubscriptionsView }: BoardButtonsProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const link = isInAllView ? `/p/all/catalog` : isInSubscriptionsView ? `/p/subscriptions/catalog` : `/p/${address}/catalog`; const params = useParams();
const createCatalogLink = () => {
if (isInAllView) {
if (params?.timeFilterName) return `/p/all/catalog/${params.timeFilterName}`;
return `/p/all/catalog`;
} else if (isInSubscriptionsView) {
if (params?.timeFilterName) return `/p/subscriptions/catalog/${params.timeFilterName}`;
return `/p/subscriptions/catalog`;
}
return `/p/${address}/catalog`;
};
return ( return (
<button className='button'> <button className='button'>
<Link to={link}>{t('catalog')}</Link> <Link to={createCatalogLink()}>{t('catalog')}</Link>
</button> </button>
); );
}; };
@@ -38,10 +50,22 @@ const SubscribeButton = ({ address }: BoardButtonsProps) => {
const ReturnButton = ({ address, isInAllView, isInSubscriptionsView }: BoardButtonsProps) => { const ReturnButton = ({ address, isInAllView, isInSubscriptionsView }: BoardButtonsProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const link = isInAllView ? `/p/all` : isInSubscriptionsView ? `/p/subscriptions` : `/p/${address}`; const params = useParams();
const createReturnLink = () => {
if (isInAllView) {
if (params?.timeFilterName) return `/p/all/${params.timeFilterName}`;
return `/p/all`;
} else if (isInSubscriptionsView) {
if (params?.timeFilterName) return `/p/subscriptions/${params.timeFilterName}`;
return `/p/subscriptions`;
}
return `/p/${address}`;
};
return ( return (
<button className='button'> <button className='button'>
<Link to={link}>{t('return')}</Link> <Link to={createReturnLink()}>{t('return')}</Link>
</button> </button>
); );
}; };
@@ -66,7 +90,7 @@ const SortOptions = () => {
}; };
return ( return (
<> <>
{t('sort_by')}:&nbsp; <span className='capitalize'>{t('sort_by')}</span>:&nbsp;
<select value={sortType} onChange={handleSortChange}> <select value={sortType} onChange={handleSortChange}>
<option value='active'>{t('bump_order')}</option> <option value='active'>{t('bump_order')}</option>
<option value='new'>{t('creation_date')}</option> <option value='new'>{t('creation_date')}</option>
+1 -1
View File
@@ -164,7 +164,7 @@ const CatalogPost = ({ post }: { post: Comment }) => {
return ( return (
<> <>
<div className={styles.post}> <div className={styles.post}>
<div onMouseOver={() => setHoveredCid(cid)} onMouseLeave={() => setHoveredCid(null)}> <div onMouseOver={() => setHoveredCid(isDescription ? 'd' : isRules ? 'r' : cid)} onMouseLeave={() => setHoveredCid(null)}>
{hasThumbnail ? ( {hasThumbnail ? (
<Link to={postLink}> <Link to={postLink}>
<div <div
+3 -1
View File
@@ -20,11 +20,13 @@ export const isCatalogView = (pathname: string, params: ParamsType): boolean =>
const decodedPathname = decodeURIComponent(pathname); const decodedPathname = decodeURIComponent(pathname);
return ( return (
decodedPathname === `/p/${subplebbitAddress}/catalog` ||
decodedPathname === `/p/${subplebbitAddress}/catalog/settings` || decodedPathname === `/p/${subplebbitAddress}/catalog/settings` ||
decodedPathname === `/p/all/catalog/settings` ||
decodedPathname === `/p/all/catalog` || decodedPathname === `/p/all/catalog` ||
decodedPathname === `/p/all/catalog/settings` ||
decodedPathname === `/p/all/catalog/${timeFilterName}` || decodedPathname === `/p/all/catalog/${timeFilterName}` ||
decodedPathname === `/p/subscriptions/catalog` || decodedPathname === `/p/subscriptions/catalog` ||
decodedPathname === `/p/subscriptions/catalog/settings` ||
decodedPathname === `/p/subscriptions/catalog/${timeFilterName}` decodedPathname === `/p/subscriptions/catalog/${timeFilterName}`
); );
}; };