diff --git a/src/components/board-buttons/board-buttons.tsx b/src/components/board-buttons/board-buttons.tsx index fd0e92d2..d0ce50fb 100644 --- a/src/components/board-buttons/board-buttons.tsx +++ b/src/components/board-buttons/board-buttons.tsx @@ -45,7 +45,12 @@ const CatalogButton = ({ address, isInAllView, isInSubscriptionsView, isInModVie if (params?.timeFilterName) return `/mod/catalog/${params.timeFilterName}`; return `/mod/catalog`; } - const boardPath = address ? getBoardPath(address, defaultSubplebbits) : defaultSubplebbits || ''; + let boardPath = ''; + if (address) { + boardPath = getBoardPath(address, defaultSubplebbits); + } else if (Array.isArray(defaultSubplebbits) && defaultSubplebbits.length > 0 && defaultSubplebbits[0]?.address) { + boardPath = getBoardPath(defaultSubplebbits[0].address, defaultSubplebbits); + } return `/${boardPath}/catalog`; }; @@ -83,7 +88,12 @@ const ReturnButton = ({ address, isInAllView, isInSubscriptionsView, isInModView if (params?.timeFilterName) return `/mod/${params.timeFilterName}`; return `/mod`; } - const boardPath = address ? getBoardPath(address, defaultSubplebbits) : defaultSubplebbits || ''; + let boardPath = ''; + if (address) { + boardPath = getBoardPath(address, defaultSubplebbits); + } else if (Array.isArray(defaultSubplebbits) && defaultSubplebbits.length > 0 && defaultSubplebbits[0]?.address) { + boardPath = getBoardPath(defaultSubplebbits[0].address, defaultSubplebbits); + } return `/${boardPath}`; }; diff --git a/src/views/board/board.tsx b/src/views/board/board.tsx index 76d45fe6..62662d01 100644 --- a/src/views/board/board.tsx +++ b/src/views/board/board.tsx @@ -190,27 +190,30 @@ const Board = () => { (isInAllView || isInSubscriptionsView || isInModView) && showMorePostsSuggestion && monthlyFeed.length > feed.length && - (weeklyFeed.length > feed.length ? ( -
- , - }} - /> -
- ) : ( -
- , - }} - /> -
- )) + (() => { + const basePath = isInAllView ? '/all' : isInSubscriptionsView ? '/subscriptions' : isInModView ? '/mod' : boardPath ? `/${boardPath}` : ''; + return weeklyFeed.length > feed.length ? ( +
+ , + }} + /> +
+ ) : ( +
+ , + }} + /> +
+ ); + })() )} ); diff --git a/src/views/not-found/not-found.tsx b/src/views/not-found/not-found.tsx index 0eb31a6b..e242aee4 100644 --- a/src/views/not-found/not-found.tsx +++ b/src/views/not-found/not-found.tsx @@ -1,6 +1,8 @@ import { useState } from 'react'; import { Link, useLocation } from 'react-router-dom'; import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits'; +import { useDefaultSubplebbits } from '../../hooks/use-default-subplebbits'; +import { getSubplebbitAddress } from '../../lib/utils/route-utils'; import { HomeLogo } from '../home'; import styles from './not-found.module.css'; import { NOT_FOUND_IMAGES } from '../../generated/asset-manifest'; @@ -16,7 +18,8 @@ const NotFound = () => { // Extract boardIdentifier from pathname (could be directory code or address) const pathParts = location.pathname.split('/').filter(Boolean); const boardIdentifier = pathParts[0] && pathParts[0] !== 'not-found' && pathParts[0] !== 'faq' ? pathParts[0] : ''; - const subplebbitAddress = boardIdentifier || ''; + const defaultSubplebbits = useDefaultSubplebbits(); + const subplebbitAddress = boardIdentifier ? getSubplebbitAddress(boardIdentifier, defaultSubplebbits) : ''; const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress]); const { address, shortAddress } = subplebbit || {}; @@ -35,7 +38,7 @@ const NotFound = () => { <>
- [Back to p/{shortAddress}] + [Back to p/{shortAddress || subplebbitAddress}]
)}