From d3c29fd6ece80c0293d5d757158373edec0912e6 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Thu, 27 Jun 2024 14:18:10 +0200 Subject: [PATCH] feat(catalog): add 'you have blocked this board' message and unblock button --- src/views/catalog/catalog.tsx | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/views/catalog/catalog.tsx b/src/views/catalog/catalog.tsx index afd5cead..53f2933a 100644 --- a/src/views/catalog/catalog.tsx +++ b/src/views/catalog/catalog.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo, useRef } from 'react'; import { useLocation, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import { useAccount, Subplebbit, useFeed, useSubplebbit, Comment } from '@plebbit/plebbit-react-hooks'; +import { Comment, useAccount, Subplebbit, useFeed, useSubplebbit, useBlock } from '@plebbit/plebbit-react-hooks'; import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso'; import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils'; import useDefaultSubplebbits from '../../hooks/use-default-subplebbits'; @@ -174,15 +174,40 @@ const Catalog = () => { ); + const { blocked, unblock } = useBlock({ address: subplebbitAddress }); + const Footer = () => { let footerContent; if (feed.length === 0) { - footerContent = t('no_posts'); + if (blocked) { + footerContent = 'you have blocked this board'; + } else { + footerContent = t('no_posts'); + } } if (hasMore || subplebbitAddresses.length === 0) { footerContent = loadingString; } - return
{footerContent}
; + return ( +
+ {footerContent} + {blocked && ( + <> +   [ + { + unblock(); + reset(); + }} + > + Unblock + + ] + + )} +
+ ); }; const isFeedLoaded = feed.length > 0 || state === 'failed';