From 2f5ca7c740ec3b1451592612a9044f01c4a2c9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Mon, 18 Jul 2022 23:00:58 +0200 Subject: [PATCH] Display 'No chats found' in a card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../features/chats/components/chat-list.tsx | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/app/soapbox/features/chats/components/chat-list.tsx b/app/soapbox/features/chats/components/chat-list.tsx index 5d9c422a8..825b64871 100644 --- a/app/soapbox/features/chats/components/chat-list.tsx +++ b/app/soapbox/features/chats/components/chat-list.tsx @@ -7,7 +7,7 @@ import { createSelector } from 'reselect'; import { fetchChats, expandChats } from 'soapbox/actions/chats'; import PullToRefresh from 'soapbox/components/pull-to-refresh'; -import { Text } from 'soapbox/components/ui'; +import { Card, Text } from 'soapbox/components/ui'; import PlaceholderChat from 'soapbox/features/placeholder/components/placeholder_chat'; import { useAppSelector } from 'soapbox/hooks'; @@ -53,6 +53,8 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false }) const hasMore = useAppSelector(state => !!state.chats.next); const isLoading = useAppSelector(state => state.chats.isLoading); + const isEmpty = chatIds.size === 0; + const handleLoadMore = useCallback(() => { if (hasMore && !isLoading) { dispatch(expandChats()); @@ -63,28 +65,30 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false }) return dispatch(fetchChats()) as any; }; + const renderEmpty = () => isLoading ? : ( + + {intl.formatMessage(messages.emptyMessage)} + + ); + return ( - ( - - )} - components={{ - ScrollSeekPlaceholder: () => , - Footer: () => hasMore ? : null, - EmptyPlaceholder: () => { - if (isLoading) { - return ; - } else { - return {intl.formatMessage(messages.emptyMessage)}; - } - }, - }} - /> + {isEmpty ? renderEmpty() : ( + ( + + )} + components={{ + ScrollSeekPlaceholder: () => , + Footer: () => hasMore ? : null, + EmptyPlaceholder: renderEmpty, + }} + /> + )} ); };