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 { 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 (
<button className='button'>
<Link to={link}>{t('catalog')}</Link>
<Link to={createCatalogLink()}>{t('catalog')}</Link>
</button>
);
};
@@ -38,10 +50,22 @@ const SubscribeButton = ({ address }: BoardButtonsProps) => {
const ReturnButton = ({ address, isInAllView, isInSubscriptionsView }: BoardButtonsProps) => {
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 (
<button className='button'>
<Link to={link}>{t('return')}</Link>
<Link to={createReturnLink()}>{t('return')}</Link>
</button>
);
};
@@ -66,7 +90,7 @@ const SortOptions = () => {
};
return (
<>
{t('sort_by')}:&nbsp;
<span className='capitalize'>{t('sort_by')}</span>:&nbsp;
<select value={sortType} onChange={handleSortChange}>
<option value='active'>{t('bump_order')}</option>
<option value='new'>{t('creation_date')}</option>
+1 -1
View File
@@ -164,7 +164,7 @@ const CatalogPost = ({ post }: { post: Comment }) => {
return (
<>
<div className={styles.post}>
<div onMouseOver={() => setHoveredCid(cid)} onMouseLeave={() => setHoveredCid(null)}>
<div onMouseOver={() => setHoveredCid(isDescription ? 'd' : isRules ? 'r' : cid)} onMouseLeave={() => setHoveredCid(null)}>
{hasThumbnail ? (
<Link to={postLink}>
<div
+3 -1
View File
@@ -20,11 +20,13 @@ export const isCatalogView = (pathname: string, params: ParamsType): boolean =>
const decodedPathname = decodeURIComponent(pathname);
return (
decodedPathname === `/p/${subplebbitAddress}/catalog` ||
decodedPathname === `/p/${subplebbitAddress}/catalog/settings` ||
decodedPathname === `/p/all/catalog/settings` ||
decodedPathname === `/p/all/catalog` ||
decodedPathname === `/p/all/catalog/settings` ||
decodedPathname === `/p/all/catalog/${timeFilterName}` ||
decodedPathname === `/p/subscriptions/catalog` ||
decodedPathname === `/p/subscriptions/catalog/settings` ||
decodedPathname === `/p/subscriptions/catalog/${timeFilterName}`
);
};