diff --git a/src/views/home/boards-list/boards-list.tsx b/src/views/home/boards-list/boards-list.tsx index ef9ea82c..e9fcd9ac 100644 --- a/src/views/home/boards-list/boards-list.tsx +++ b/src/views/home/boards-list/boards-list.tsx @@ -8,10 +8,9 @@ import useBoardsFilterStore from '../../../stores/use-boards-filter-store'; import BoardsFilterModal from './boards-filter-modal'; import styles from '../home.module.css'; -// Helper function to find board address by matching title pattern -const findBoardAddress = (multisub: DirectoryCommunity[], titlePattern: string): string | null => { - const entry = multisub.find((ms) => ms.title === titlePattern); - return entry?.address || null; +const getBoardNameFromDirectoryTitle = (title: string): string => { + const match = title.match(/^\/[^/]+\/\s*-\s*(.+)$/); + return match?.[1]?.trim() || title.trim(); }; const NSFWBadge = () => { @@ -55,9 +54,37 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => { openDirectoryModal(); }; - // Find active boards - const bizAddress = findBoardAddress(multisub, '/biz/ - Business & Finance'); - const polAddress = findBoardAddress(multisub, '/pol/ - Politically Incorrect'); + const boardAddressesByName = multisub.reduce>((acc, community) => { + if (!community.title) return acc; + const boardName = getBoardNameFromDirectoryTitle(community.title); + if (!acc[boardName]) { + acc[boardName] = community.address; + } + return acc; + }, {}); + + const renderBoardLink = (boardName: string) => { + const address = boardAddressesByName[boardName]; + + if (address) { + return ( +
  • + handleLinkClick(e, address)}> + {boardName} + +
  • + ); + } + + return ( +
  • + + {boardName} + +
  • + ); + }; + const errorMessage = error?.message; // Filtering logic: determine which categories to show @@ -93,62 +120,20 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => { @@ -160,46 +145,14 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => { <>

    Video Games

    )} @@ -211,81 +164,21 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => {

    Interests

    )} @@ -295,88 +188,26 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => {

    Creative

    @@ -391,64 +222,16 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => { <>

    Other

    )} @@ -459,44 +242,12 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => {

    Misc.

      -
    • - - Random - -
    • -
    • - - ROBOT9001 - -
    • - {polAddress ? ( -
    • - handleLinkClick(e, polAddress)}> - Politically Incorrect - -
    • - ) : ( -
    • - - Politically Incorrect - -
    • - )} -
    • - - International/Random - -
    • -
    • - - Cams & Meetups - -
    • -
    • - - Shit 5chan Says - -
    • + {renderBoardLink('Random')} + {renderBoardLink('ROBOT9001')} + {renderBoardLink('Politically Incorrect')} + {renderBoardLink('International/Random')} + {renderBoardLink('Cams & Meetups')} + {renderBoardLink('Shit 5chan Says')}
    )} @@ -509,71 +260,19 @@ const BoardsList = ({ multisub }: { multisub: DirectoryCommunity[] }) => {

    Adult

      -
    • - - Sexy Beautiful Women - -
    • -
    • - - Hardcore - -
    • -
    • - - Handsome Men - -
    • -
    • - - Hentai - -
    • -
    • - - Ecchi - -
    • -
    • - - Yuri - -
    • -
    • - - Hentai/Alternative - -
    • -
    • - - Yaoi - -
    • -
    • - - Torrents - -
    • -
    • - - High Resolution - -
    • -
    • - - Adult GIF - -
    • -
    • - - Adult Cartoons - -
    • -
    • - - Adult Requests - -
    • + {renderBoardLink('Sexy Beautiful Women')} + {renderBoardLink('Hardcore')} + {renderBoardLink('Handsome Men')} + {renderBoardLink('Hentai')} + {renderBoardLink('Ecchi')} + {renderBoardLink('Yuri')} + {renderBoardLink('Hentai/Alternative')} + {renderBoardLink('Yaoi')} + {renderBoardLink('Torrents')} + {renderBoardLink('High Resolution')} + {renderBoardLink('Adult GIF')} + {renderBoardLink('Adult Cartoons')} + {renderBoardLink('Adult Requests')}
    )}