import * as React from 'react';
import styled from 'styled-components';
import { Users } from 'react-feather';
import { GridWrapper } from 'src/components/gridWrapper/GridWrapper';
import { withApollo } from 'config/client';
import { ChatInit } from 'src/components/chat/ChatInit';
import { ChatFetcher } from 'src/components/chat/ChatFetcher';
import { useChatState } from '../src/context/ChatContext';
import { separateBySender, getSenders } from '../src/utils/chat';
import {
CardWithTitle,
SubTitle,
Card,
SingleLine,
} from '../src/components/generic/Styled';
import { Contacts } from '../src/views/chat/Contacts';
import { ChatBox } from '../src/views/chat/ChatBox';
import { ChatStart } from '../src/views/chat/ChatStart';
import { useStatusState } from '../src/context/StatusContext';
import { Text } from '../src/components/typography/Styled';
import { LoadingCard } from '../src/components/loading/LoadingCard';
import { ChatCard } from '../src/views/chat/Chat.styled';
import { ViewSwitch } from '../src/components/viewSwitch/ViewSwitch';
import { ColorButton } from '../src/components/buttons/colorButton/ColorButton';
const ChatLayout = styled.div`
display: flex;
${({ withHeight = true }: { withHeight: boolean }) =>
withHeight && 'height: 600px'}
`;
const ChatView = () => {
const { minorVersion } = useStatusState();
const { chats, sender, sentChats, initialized } = useChatState();
const bySender = separateBySender([...chats, ...sentChats]);
const senders = getSenders(bySender) || [];
const [user, setUser] = React.useState('');
const [showContacts, setShowContacts] = React.useState(false);
if (!initialized) {
return ;
}
if (minorVersion < 9 && initialized) {
return (
Chat
Chatting with other nodes is only available for nodes with LND
versions 0.9.0-beta and up.
If you want to use this feature please update your node.
);
}
const renderChats = () => {
if (showContacts) {
return (
);
}
return (
{user === 'New Chat' ? (
) : (
)}
);
};
return (
{!showContacts && user !== 'New Chat' && (
<>
Chat
setShowContacts(prev => !prev)}>
{user}
>
)}
{chats.length <= 0 && sentChats.length <= 0 ? (
) : (
renderChats()
)}
);
};
const Wrapped = () => (
);
export default withApollo(Wrapped);