From 8439084587fa86e5cb4b86a41cb232350ceec668 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 26 Sep 2024 14:47:56 +0200 Subject: [PATCH] [Glitch] Add fallback to domain block confirmation modal Port 7a62d57427f925f3e7de4444cb25c5c190425161 to glitch-soc Signed-off-by: Claire --- .../ui/components/domain_block_modal.tsx | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/app/javascript/flavours/glitch/features/ui/components/domain_block_modal.tsx b/app/javascript/flavours/glitch/features/ui/components/domain_block_modal.tsx index c5aff4043d..b056db7f6f 100644 --- a/app/javascript/flavours/glitch/features/ui/components/domain_block_modal.tsx +++ b/app/javascript/flavours/glitch/features/ui/components/domain_block_modal.tsx @@ -30,9 +30,9 @@ export const DomainBlockModal: React.FC<{ }> = ({ domain, accountId, acct }) => { const dispatch = useAppDispatch(); const [loading, setLoading] = useState(true); - const [preview, setPreview] = useState( - null, - ); + const [preview, setPreview] = useState< + DomainBlockPreviewResponse | 'error' | null + >(null); const handleClick = useCallback(() => { if (loading) { @@ -65,6 +65,7 @@ export const DomainBlockModal: React.FC<{ return ''; }) .catch(() => { + setPreview('error'); setLoading(false); }); }, [setPreview, setLoading, domain]); @@ -89,7 +90,35 @@ export const DomainBlockModal: React.FC<{
- {preview && preview.followers_count + preview.following_count > 0 && ( + {preview && + preview !== 'error' && + preview.followers_count + preview.following_count > 0 && ( +
+
+ +
+
+ + + ), + followingCount: preview.following_count, + followingCountDisplay: ( + + ), + }} + /> + +
+
+ )} + + {preview === 'error' && (
@@ -97,18 +126,8 @@ export const DomainBlockModal: React.FC<{
- ), - followingCount: preview.following_count, - followingCountDisplay: ( - - ), - }} + id='domain_block_modal.you_will_lose_relationships' + defaultMessage='You will lose all followers and people you follow from this server.' />