From bae6faa9291a4633b6da0b3aa0e6ced3e46a6d20 Mon Sep 17 00:00:00 2001 From: plebeius Date: Mon, 3 Nov 2025 22:06:18 +0100 Subject: [PATCH] feat: implement 5chan-specific default board list --- README.md | 2 +- src/app.tsx | 83 ++++++++-------- src/constants/nsfwTags.ts | 2 - src/hooks/use-auto-subscribe.ts | 77 --------------- src/hooks/use-default-subplebbits.ts | 41 ++------ src/hooks/use-initial-theme.ts | 5 +- src/hooks/use-popular-posts.ts | 17 +++- src/hooks/use-theme.ts | 5 +- src/stores/use-auto-subscribe-store.ts | 25 ----- src/views/catalog/catalog.tsx | 11 +-- src/views/home/boards-list/boards-list.tsx | 97 +++---------------- src/views/home/home.tsx | 2 +- .../popular-threads-box.tsx | 8 +- 13 files changed, 87 insertions(+), 288 deletions(-) delete mode 100644 src/constants/nsfwTags.ts delete mode 100644 src/hooks/use-auto-subscribe.ts delete mode 100644 src/stores/use-auto-subscribe-store.ts diff --git a/README.md b/README.md index 690cbdba..522a649f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ In the plebbit protocol, a 5chan board is called a _subplebbit_. To run a subple Peers can connect to your subplebbit using any plebbit client, such as 5chan or Seedit. They only need the subplebbit's address, which is not stored in any central database, as plebbit is a pure peer-to-peer protocol. ### How to add a board to the boards list -The boards list on 5chan is plebbit's [temporary-default-subplebbits](https://github.com/plebbit/temporary-default-subplebbits) list. You can open a pull request in that repo to add your subplebbit to the list, or contact devs via telegram [@plebbit](https://t.me/plebbit). In the future, this process will be automated by submitting proposals to a plebbit DAO, using the [plebbit token](https://etherscan.io/token/0xea81dab2e0ecbc6b5c4172de4c22b6ef6e55bd8f). +The boards list on 5chan is plebbit's [lists](https://github.com/plebbit/lists) repository, specifically the [5chan-multisub.json](https://github.com/plebbit/lists/blob/master/5chan-multisub.json) file. You can open a pull request in that repo to add your subplebbit to the list, or contact devs via telegram [@plebbit](https://t.me/plebbit). In the future, this process will be automated by submitting proposals to a plebbit DAO, using the [plebbit token](https://etherscan.io/token/0xea81dab2e0ecbc6b5c4172de4c22b6ef6e55bd8f). ## To run locally diff --git a/src/app.tsx b/src/app.tsx index 00d5c73c..5ae3aea6 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,7 +5,6 @@ import { initSnow, removeSnow } from './lib/snow'; import { isAllView, isModView, isSubscriptionsView } from './lib/utils/view-utils'; import useReplyModalStore from './stores/use-reply-modal-store'; import useSpecialThemeStore from './stores/use-special-theme-store'; -import { useAutoSubscribe } from './hooks/use-auto-subscribe'; import useIsMobile from './hooks/use-is-mobile'; import useTheme from './hooks/use-theme'; import styles from './app.module.css'; @@ -117,54 +116,50 @@ const GlobalLayout = () => { ); }; -const App = () => { - useAutoSubscribe(); +const App = () => ( +
+ + }> + } /> + } /> + } /> + } /> + }> + } /> + } /> + } /> + } /> - return ( -
- - }> - } /> - } /> - } /> - } /> - }> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> - - } /> - } /> - - } /> + } /> + } /> - -
- ); -}; + } /> + +
+
+); export default App; diff --git a/src/constants/nsfwTags.ts b/src/constants/nsfwTags.ts deleted file mode 100644 index 38e09d6d..00000000 --- a/src/constants/nsfwTags.ts +++ /dev/null @@ -1,2 +0,0 @@ -// 5chan shouldn't consider 'vulgar' or 'anti' as nsfw tags, unlike more sfw-oriented clients -export const nsfwTags = ['adult', 'gore']; diff --git a/src/hooks/use-auto-subscribe.ts b/src/hooks/use-auto-subscribe.ts deleted file mode 100644 index ff267547..00000000 --- a/src/hooks/use-auto-subscribe.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { useEffect } from 'react'; -import { useAccount, setAccount } from '@plebbit/plebbit-react-hooks'; -import { getAutoSubscribeAddresses, useDefaultSubplebbits } from './use-default-subplebbits'; -import { useAutoSubscribeStore } from '../stores/use-auto-subscribe-store'; - -const AUTO_SUBSCRIBE_KEY_PREFIX = '5chan-auto-subscribe-done-'; - -// Keep track of which accounts have been processed globally -const processedAccounts = new Set(); - -export const useAutoSubscribe = () => { - const account = useAccount(); - const accountAddress = account?.author?.address; - const defaultSubplebbits = useDefaultSubplebbits(); - const { addCheckingAccount, removeCheckingAccount, isCheckingAccount } = useAutoSubscribeStore(); - - useEffect(() => { - if (!accountAddress) return; - - // Mark as checking immediately when account changes - addCheckingAccount(accountAddress); - - const processAutoSubscribe = async () => { - if (!account || !defaultSubplebbits?.length) return; - - if (processedAccounts.has(accountAddress)) { - removeCheckingAccount(accountAddress); - return; - } - - const storageKey = AUTO_SUBSCRIBE_KEY_PREFIX + accountAddress; - const hasAutoSubscribed = localStorage.getItem(storageKey); - - if (account.subscriptions?.length > 0 || hasAutoSubscribed) { - processedAccounts.add(accountAddress); - removeCheckingAccount(accountAddress); - return; - } - - const autoSubscribeAddresses = getAutoSubscribeAddresses(); - if (autoSubscribeAddresses.length) { - try { - const currentSubscriptions = account.subscriptions || []; - - const mergedSubscriptions = [...currentSubscriptions]; - - for (const address of autoSubscribeAddresses) { - if (!mergedSubscriptions.includes(address)) { - mergedSubscriptions.push(address); - } - } - - await setAccount({ - ...account, - subscriptions: mergedSubscriptions, - }); - localStorage.setItem(storageKey, 'true'); - } catch (error) { - console.error('Auto-subscribe error:', error); - } - } - - processedAccounts.add(accountAddress); - removeCheckingAccount(accountAddress); - }; - - processAutoSubscribe(); - - return () => { - if (accountAddress) removeCheckingAccount(accountAddress); - }; - }, [account, accountAddress, defaultSubplebbits, addCheckingAccount, removeCheckingAccount]); - - return { - isCheckingSubscriptions: !accountAddress || isCheckingAccount(accountAddress), - }; -}; diff --git a/src/hooks/use-default-subplebbits.ts b/src/hooks/use-default-subplebbits.ts index 4de798b2..6f3cb187 100644 --- a/src/hooks/use-default-subplebbits.ts +++ b/src/hooks/use-default-subplebbits.ts @@ -10,10 +10,7 @@ export interface MultisubMetadata { export interface MultisubSubplebbit { title?: string; address: string; - tags?: string[]; - features?: string[]; - autoSubscribe5Chan?: boolean; - lowUptime?: boolean; + nsfw?: boolean; } export interface DefaultSubplebbitsState { @@ -24,7 +21,6 @@ export interface DefaultSubplebbitsState { let cacheSubplebbits: MultisubSubplebbit[] | null = null; let cacheMetadata: MultisubMetadata | null = null; -let cacheAutoSubscribeAddresses: string[] | null = null; export const useDefaultSubplebbits = () => { const [state, setState] = useState({ @@ -45,24 +41,17 @@ export const useDefaultSubplebbits = () => { (async () => { try { - const multisub = await fetch('https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/multisub.json').then((res) => { + const multisub = await fetch('https://raw.githubusercontent.com/plebbit/lists/master/5chan-multisub.json').then((res) => { if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return res.json(); }); - const filteredSubplebbits = multisub.subplebbits.filter((sub: MultisubSubplebbit) => !sub.lowUptime); - - cacheSubplebbits = filteredSubplebbits; - - // Cache auto-subscribe addresses when we fetch subplebbits - cacheAutoSubscribeAddresses = filteredSubplebbits - .filter((sub: MultisubSubplebbit) => sub.autoSubscribe5Chan && sub.address) - .map((sub: MultisubSubplebbit) => sub.address); + cacheSubplebbits = multisub.subplebbits; setState({ - subplebbits: filteredSubplebbits, + subplebbits: multisub.subplebbits, loading: false, error: null, }); @@ -81,8 +70,6 @@ export const useDefaultSubplebbits = () => { return cacheSubplebbits || state.subplebbits; }; -export const getAutoSubscribeAddresses = () => cacheAutoSubscribeAddresses || []; - export const useDefaultSubplebbitsState = () => { const [state, setState] = useState({ subplebbits: cacheSubplebbits || [], @@ -102,13 +89,15 @@ export const useDefaultSubplebbitsState = () => { (async () => { try { - const multisub = await fetch('https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/multisub.json').then((res) => { + const multisub = await fetch('https://raw.githubusercontent.com/plebbit/lists/master/5chan-multisub.json').then((res) => { if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return res.json(); }); + cacheSubplebbits = multisub.subplebbits; + setState({ subplebbits: multisub.subplebbits, loading: false, @@ -143,7 +132,7 @@ export const useMultisubMetadata = () => { (async () => { try { const multisub = await fetch( - 'https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/multisub.json', + 'https://raw.githubusercontent.com/plebbit/lists/master/5chan-multisub.json', // { cache: 'no-cache' } ).then((res) => res.json()); const { title, description, createdAt, updatedAt } = multisub; @@ -158,17 +147,3 @@ export const useMultisubMetadata = () => { return cacheMetadata || metadata; }; - -const getUniqueTags = (multisub: any) => { - const allTags = new Set(); - Object.values(multisub).forEach((sub: any) => { - if (sub?.tags?.length) { - sub.tags.forEach((tag: string) => allTags.add(tag)); - } - }); - return Array.from(allTags).sort(); -}; - -export const useDefaultSubplebbitTags = (subplebbits: any) => { - return useMemo(() => getUniqueTags(subplebbits), [subplebbits]); -}; diff --git a/src/hooks/use-initial-theme.ts b/src/hooks/use-initial-theme.ts index f4379e04..65b2b9a8 100644 --- a/src/hooks/use-initial-theme.ts +++ b/src/hooks/use-initial-theme.ts @@ -3,7 +3,6 @@ import { useLocation, useParams } from 'react-router-dom'; import useThemeStore from '../stores/use-theme-store'; import { useDefaultSubplebbits } from './use-default-subplebbits'; import { isAllView, isHomeView, isNotFoundView, isPendingPostView, isSubscriptionsView, isModView } from '../lib/utils/view-utils'; -import { nsfwTags } from '../constants/nsfwTags'; import { useAccountComment } from '@plebbit/plebbit-react-hooks'; const useInitialTheme = (pendingPostSubplebbitAddress?: string) => { @@ -29,7 +28,7 @@ const useInitialTheme = (pendingPostSubplebbitAddress?: string) => { const subplebbitAddress = pendingPostSubplebbitAddress || pendingPost?.subplebbitAddress; if (subplebbitAddress) { const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress); - if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) { + if (subplebbit?.nsfw) { theme = themes.nsfw || 'yotsuba'; } else { theme = themes.sfw || 'yotsuba-b'; @@ -43,7 +42,7 @@ const useInitialTheme = (pendingPostSubplebbitAddress?: string) => { theme = 'yotsuba'; } else if (paramsSubplebbitAddress) { const subplebbit = subplebbits.find((s) => s.address === paramsSubplebbitAddress); - if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) { + if (subplebbit?.nsfw) { theme = themes.nsfw || 'yotsuba'; } else { theme = themes.sfw || 'yotsuba-b'; diff --git a/src/hooks/use-popular-posts.ts b/src/hooks/use-popular-posts.ts index df65f928..6b1385a7 100644 --- a/src/hooks/use-popular-posts.ts +++ b/src/hooks/use-popular-posts.ts @@ -22,7 +22,18 @@ const usePopularPosts = (subplebbits: Subplebbit[]) => { if (subplebbit?.posts?.pages?.hot?.comments) { for (const post of Object.values(subplebbit.posts.pages.hot.comments as Comment)) { - const { deleted, link, linkHeight, linkWidth, locked, pinned, removed, replyCount, thumbnailUrl, timestamp } = post; + const { + deleted, + link, + linkHeight, + linkWidth, + locked, + pinned, + removed, + replyCount, + thumbnailUrl, + // timestamp + } = post; try { const commentMediaInfo = getCommentMediaInfo(link, thumbnailUrl, linkWidth, linkHeight); @@ -30,12 +41,12 @@ const usePopularPosts = (subplebbits: Subplebbit[]) => { if ( hasThumbnail && - (replyCount > 0 || postsPerSub > 1) && + replyCount > 1 && !deleted && !removed && !locked && !pinned && - timestamp > Date.now() / 1000 - 60 * 60 * 24 * 30 && + // timestamp > Date.now() / 1000 - 60 * 60 * 24 * 30 && !uniqueLinks.has(link) ) { subplebbitPosts.push(post); diff --git a/src/hooks/use-theme.ts b/src/hooks/use-theme.ts index e3723cb2..2084dab2 100644 --- a/src/hooks/use-theme.ts +++ b/src/hooks/use-theme.ts @@ -3,7 +3,6 @@ import { useLocation, useParams } from 'react-router-dom'; import { isAllView, isSubscriptionsView, isModView } from '../lib/utils/view-utils'; import useThemeStore from '../stores/use-theme-store'; import { useDefaultSubplebbits } from './use-default-subplebbits'; -import { nsfwTags } from '../constants/nsfwTags'; import { useAccountComment } from '@plebbit/plebbit-react-hooks'; import useSpecialThemeStore from '../stores/use-special-theme-store'; import { isChristmas } from '../lib/utils/time-utils'; @@ -64,7 +63,7 @@ const useTheme = (): [string, (theme: string) => void] => { storedTheme = themes.sfw; } else if (subplebbitAddress) { const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress); - if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) { + if (subplebbit?.nsfw) { storedTheme = themes.nsfw; } else { storedTheme = themes.sfw; @@ -85,7 +84,7 @@ const useTheme = (): [string, (theme: string) => void] => { await setThemeStore('sfw', newTheme); } else if (subplebbitAddress) { const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress); - if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) { + if (subplebbit?.nsfw) { await setThemeStore('nsfw', newTheme); } else { await setThemeStore('sfw', newTheme); diff --git a/src/stores/use-auto-subscribe-store.ts b/src/stores/use-auto-subscribe-store.ts deleted file mode 100644 index c65bceb1..00000000 --- a/src/stores/use-auto-subscribe-store.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { create } from 'zustand'; - -interface AutoSubscribeState { - checkingAccounts: Set; - addCheckingAccount: (address: string) => void; - removeCheckingAccount: (address: string) => void; - isCheckingAccount: (address: string) => boolean; - reset: () => void; -} - -export const useAutoSubscribeStore = create((set, get) => ({ - checkingAccounts: new Set(), - addCheckingAccount: (address) => - set((state) => ({ - checkingAccounts: new Set(state.checkingAccounts).add(address), - })), - removeCheckingAccount: (address) => - set((state) => { - const newSet = new Set(state.checkingAccounts); - newSet.delete(address); - return { checkingAccounts: newSet }; - }), - isCheckingAccount: (address) => get().checkingAccounts.has(address), - reset: () => set({ checkingAccounts: new Set() }), -})); diff --git a/src/views/catalog/catalog.tsx b/src/views/catalog/catalog.tsx index cb401ba0..382755a0 100644 --- a/src/views/catalog/catalog.tsx +++ b/src/views/catalog/catalog.tsx @@ -129,7 +129,7 @@ const Catalog = () => { const isInAllView = isAllView(location.pathname); const defaultSubplebbits = useDefaultSubplebbits(); - const { hideAdultBoards, hideGoreBoards } = useInterfaceSettingsStore(); + const { hideAdultBoards } = useInterfaceSettingsStore(); const { showTextOnlyThreads, filterItems, searchText, clearMatchedFilters } = useCatalogFiltersStore(); const account = useAccount(); @@ -139,11 +139,8 @@ const Catalog = () => { const subplebbitAddresses = useMemo(() => { const filteredDefaultSubplebbits = defaultSubplebbits .filter((subplebbit) => { - const { tags } = subplebbit; - const hasGoreTag = tags?.includes('gore'); - const hasAdultTag = tags?.includes('adult'); - - if ((hasGoreTag && hideGoreBoards) || (hasAdultTag && hideAdultBoards)) { + // Hide NSFW boards if hideAdultBoards is enabled (treating NSFW as adult content) + if (subplebbit.nsfw && hideAdultBoards) { return false; } return true; @@ -159,7 +156,7 @@ const Catalog = () => { } // Only include subplebbitAddress if it's defined return subplebbitAddress ? [subplebbitAddress] : []; - }, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbits, subscriptions, hideAdultBoards, hideGoreBoards]); + }, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbits, subscriptions, hideAdultBoards]); const { imageSize } = useCatalogStyleStore(); const columnWidth = imageSize === 'Large' ? 270 : 180; diff --git a/src/views/home/boards-list/boards-list.tsx b/src/views/home/boards-list/boards-list.tsx index a778e910..45060341 100644 --- a/src/views/home/boards-list/boards-list.tsx +++ b/src/views/home/boards-list/boards-list.tsx @@ -1,95 +1,38 @@ -import { useState, useEffect } from 'react'; -import { Link, useLocation } from 'react-router-dom'; +import { useState } from 'react'; +import { Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import Plebbit from '@plebbit/plebbit-js'; -import { Subplebbit, useSubplebbitStats } from '@plebbit/plebbit-react-hooks'; -import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits'; -import { useDefaultSubplebbitsState, useDefaultSubplebbitTags } from '../../../hooks/use-default-subplebbits'; +import { useDefaultSubplebbitsState, MultisubSubplebbit } from '../../../hooks/use-default-subplebbits'; import useIsMobile from '../../../hooks/use-is-mobile'; -import useIsSubplebbitOffline from '../../../hooks/use-is-subplebbit-offline'; import LoadingEllipsis from '../../../components/loading-ellipsis'; -import Tooltip from '../../../components/tooltip'; import styles from './boards-list.module.css'; -import { nsfwTags } from '../../../constants/nsfwTags'; -const Board = ({ subplebbit, isMobile }: { subplebbit: Subplebbit; isMobile: boolean }) => { +const Board = ({ subplebbit, isMobile }: { subplebbit: MultisubSubplebbit; isMobile: boolean }) => { const { t } = useTranslation(); - const { address, tags } = subplebbit || {}; - const nsfwTag = tags?.find((tag: string) => nsfwTags.includes(tag)); - - let stats = useSubplebbitStats({ subplebbitAddress: address }); - - const subplebbitData = useSubplebbitsStore((state) => state.subplebbits[address]); - const { isOffline, isOnlineStatusLoading, offlineIconClass, offlineTitle } = useIsSubplebbitOffline(subplebbitData); - + const { address, title, nsfw } = subplebbit || {}; const displayAddress = address && Plebbit.getShortAddress(address); - const showOfflineIcon = address && (isOffline || isOnlineStatusLoading); - - const title = - subplebbitData?.title || - (subplebbitData?.updatedAt ? ( - displayAddress.endsWith('.eth') || displayAddress.endsWith('.sol') ? ( - displayAddress.slice(0, -4) - ) : ( - displayAddress - ) - ) : ( - {isOffline ? t('board_not_reachable') : t('loading_board')} - )); return (

{displayAddress} - {nsfwTag && ({t(nsfwTag)})} - {showOfflineIcon && ( - - - - - - )} + {nsfw && ({t('nsfw')})}

-

{title}

+

{title || displayAddress}

- {!isMobile && ( - <> - -

{stats.hourPostCount ?? ?}

- - -

- {tags.map((tag: string, index: number) => ( - - {tag} - {index < tags.length - 1 && ', '} - - ))} -

- - - )} ); }; -const BoardsList = ({ multisub }: { multisub: Subplebbit[] }) => { +const BoardsList = ({ multisub }: { multisub: MultisubSubplebbit[] }) => { const { t } = useTranslation(); - const location = useLocation(); const [displayCount, setDisplayCount] = useState(15); const isMobile = useIsMobile(); const { loading, error } = useDefaultSubplebbitsState(); - const currentTag = location.pathname.split('/').filter(Boolean)[0]; - const tags = useDefaultSubplebbitTags(multisub); - - useEffect(() => { - setDisplayCount(15); - }, [currentTag]); - if (loading) { return (
@@ -108,12 +51,9 @@ const BoardsList = ({ multisub }: { multisub: Subplebbit[] }) => { ); } - const filteredBoards = (currentTag && tags.includes(currentTag) ? multisub.filter((sub) => sub?.tags?.includes(currentTag)) : multisub).slice(0, displayCount); - - const totalBoardCount = currentTag && tags.includes(currentTag) ? multisub.filter((sub) => sub?.tags?.includes(currentTag)).length : multisub.length; - - const hasMoreBoards = - currentTag && tags.includes(currentTag) ? displayCount < multisub.filter((sub) => sub?.tags?.includes(currentTag)).length : displayCount < multisub.length; + const filteredBoards = multisub.slice(0, displayCount); + const totalBoardCount = multisub.length; + const hasMoreBoards = displayCount < multisub.length; return (
@@ -126,12 +66,6 @@ const BoardsList = ({ multisub }: { multisub: Subplebbit[] }) => { {t('board')} {t('title')} - {!isMobile && ( - - PPH - - )} - {!isMobile && {t('tags')}} @@ -141,14 +75,7 @@ const BoardsList = ({ multisub }: { multisub: Subplebbit[] }) => {
- {currentTag && tags.includes(currentTag) - ? t('displaying_boards_with_tag', { - filteredBoardsCount: filteredBoards.length, - totalBoardCount: totalBoardCount, - currentTag: `"${currentTag}"`, - interpolation: { escapeValue: false }, - }) - : t('displaying_boards', { filteredBoardsCount: filteredBoards.length, totalBoardCount: totalBoardCount, interpolation: { escapeValue: false } })} + {t('displaying_boards', { filteredBoardsCount: filteredBoards.length, totalBoardCount: totalBoardCount, interpolation: { escapeValue: false } })}
{hasMoreBoards && (
diff --git a/src/views/home/home.tsx b/src/views/home/home.tsx index ad930eda..e4e5b0e7 100644 --- a/src/views/home/home.tsx +++ b/src/views/home/home.tsx @@ -10,7 +10,7 @@ import BoardsList from './boards-list'; import Version from '../../components/version'; import _ from 'lodash'; -// https://github.com/plebbit/temporary-default-subplebbits/blob/master/README.md +// https://github.com/plebbit/lists/blob/master/5chan-multisub.json const SearchBar = () => { const searchInputRef = useRef(null); diff --git a/src/views/home/popular-threads-box/popular-threads-box.tsx b/src/views/home/popular-threads-box/popular-threads-box.tsx index 68e65ea3..b279e730 100644 --- a/src/views/home/popular-threads-box/popular-threads-box.tsx +++ b/src/views/home/popular-threads-box/popular-threads-box.tsx @@ -9,7 +9,7 @@ import { getCommentMediaInfo } from '../../../lib/utils/media-utils'; import { CatalogPostMedia } from '../../../components/catalog-row'; import LoadingEllipsis from '../../../components/loading-ellipsis'; import BoxModal from '../box-modal'; -import { nsfwTags } from '../../../constants/nsfwTags'; +import { MultisubSubplebbit } from '../../../hooks/use-default-subplebbits'; import { removeMarkdown } from '../../../lib/utils/post-utils'; interface PopularThreadProps { @@ -50,7 +50,7 @@ const PopularThreadCard = ({ post, boardTitle, boardShortAddress }: PopularThrea ); }; -const PopularThreadsBox = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebbits: any }) => { +const PopularThreadsBox = ({ multisub, subplebbits }: { multisub: MultisubSubplebbit[]; subplebbits: any }) => { const { t } = useTranslation(); const { showWorksafeContentOnly, showNsfwContentOnly } = usePopularThreadsOptionsStore(); @@ -58,13 +58,13 @@ const PopularThreadsBox = ({ multisub, subplebbits }: { multisub: Subplebbit[]; if (showWorksafeContentOnly) { return subplebbits.filter((sub: Subplebbit) => { const multisubEntry = multisub.find((ms) => ms?.address === sub?.address); - return multisubEntry ? !multisubEntry.tags.some((tag: string) => nsfwTags.includes(tag)) : true; + return multisubEntry ? !multisubEntry.nsfw : true; }); } if (showNsfwContentOnly) { return subplebbits.filter((sub: Subplebbit) => { const multisubEntry = multisub.find((ms) => ms?.address === sub?.address); - return multisubEntry ? multisubEntry.tags.some((tag: string) => nsfwTags.includes(tag)) : false; + return multisubEntry ? multisubEntry.nsfw : false; }); } return subplebbits;