pl-fe: improve cond

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-01 19:19:48 +02:00
parent 767a23b19f
commit f3a03dd38b
2 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import PullToRefresh from 'pl-fe/components/pull-to-refresh';
import Spinner from 'pl-fe/components/ui/spinner';
import Stack from 'pl-fe/components/ui/stack';
import PlaceholderChat from 'pl-fe/features/placeholder/components/placeholder-chat';
import { useFeatures } from 'pl-fe/hooks/use-features';
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
import { useChats } from 'pl-fe/queries/chats';
import ChatListItem from './chat-list-item';
@ -20,10 +20,10 @@ interface IChatList {
}
const ChatList: React.FC<IChatList> = ({ onClickChat, useWindowScroll = false }) => {
const { shoutbox } = useFeatures();
const showShoutbox = useAppSelector((state) => !state.shoutbox.isLoading);
const { chatsQuery: { data: chats, isFetching, hasNextPage, fetchNextPage, refetch } } = useChats();
const allChats: Array<Chat | 'shoutbox'> | undefined = shoutbox ? ['shoutbox', ...(chats || [])] : chats;
const allChats: Array<Chat | 'shoutbox'> | undefined = showShoutbox ? ['shoutbox', ...(chats || [])] : chats;
const [isNearBottom, setNearBottom] = useState<boolean>(false);
const [isNearTop, setNearTop] = useState<boolean>(true);

View File

@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';
import Stack from 'pl-fe/components/ui/stack';
import { ChatWidgetScreens, useChatContext } from 'pl-fe/contexts/chat-context';
import { useStatContext } from 'pl-fe/contexts/stat-context';
import { useFeatures } from 'pl-fe/hooks/use-features';
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
import { useChats } from 'pl-fe/queries/chats';
import ChatList from '../chat-list';
@ -20,7 +20,7 @@ import type { Chat } from 'pl-api';
const ChatPane = () => {
const { unreadChatsCount } = useStatContext();
const { shoutbox } = useFeatures();
const showShoutbox = useAppSelector((state) => !state.shoutbox.isLoading);
const { screen, changeScreen, isOpen, toggleChatPane } = useChatContext();
const { chatsQuery: { data: chats, isLoading } } = useChats();
@ -34,7 +34,7 @@ const ChatPane = () => {
};
const renderBody = () => {
if (Number(chats?.length) > 0 || shoutbox || isLoading) {
if (Number(chats?.length) > 0 || showShoutbox || isLoading) {
return (
<Stack space={4} className='h-full grow'>
<ChatList onClickChat={handleClickChat} />