Replace empty state (#116)

This commit is contained in:
Maria Rushkova 2021-11-05 16:24:14 +01:00 committed by GitHub
parent faffa272e1
commit 84624011f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 17 deletions

View File

@ -82,6 +82,7 @@ export function Channels({
setActiveChannel({ setActiveChannel({
id: group.join(""), id: group.join(""),
name: group.join(", ").slice(0, 10), name: group.join(", ").slice(0, 10),
type: "group",
}); });
setCreateChat(false); setCreateChat(false);
if (onCommunityClick) { if (onCommunityClick) {
@ -106,6 +107,7 @@ export function Channels({
setActiveChannel({ setActiveChannel({
id: member, id: member,
name: member.slice(0, 10), name: member.slice(0, 10),
type: "dm",
description: "Contact", description: "Contact",
}); });
if (onCommunityClick) { if (onCommunityClick) {

View File

@ -32,7 +32,8 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
{channel.type === "dm" ? ( {channel.type === "dm" ? (
<EmptyText> <EmptyText>
Any messages you send here are encrypted and can only be read by you Any messages you send here are encrypted and can only be read by you
and <span>{channel.name.slice(0, 10)}</span>. and <br />
<span>{channel.name.slice(0, 10)}</span>.
</EmptyText> </EmptyText>
) : channel.type === "group" ? ( ) : channel.type === "group" ? (
<EmptyText> <EmptyText>
@ -42,7 +43,8 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
</EmptyText> </EmptyText>
) : ( ) : (
<EmptyText> <EmptyText>
Welcome to the beginning of the <span>#{channel.name}</span> channel! Welcome to the beginning of the <span>#{channel.name}</span> <br />
channel!
</EmptyText> </EmptyText>
)} )}
</Wrapper> </Wrapper>
@ -53,8 +55,7 @@ const Wrapper = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
height: calc(100% - 44px); margin-bottom: 32px;
padding: 8px 16px 0;
`; `;
const ChannelInfoEmpty = styled(ChannelInfo)` const ChannelInfoEmpty = styled(ChannelInfo)`
@ -85,7 +86,6 @@ const EmptyText = styled.p`
color: ${({ theme }) => theme.secondary}; color: ${({ theme }) => theme.secondary};
max-width: 310px; max-width: 310px;
text-align: center; text-align: center;
word-break: break-all;
& > span { & > span {
color: ${({ theme }) => theme.primary}; color: ${({ theme }) => theme.primary};

View File

@ -6,7 +6,6 @@ import { useMessengerContext } from "../../contexts/messengerProvider";
import { useNarrow } from "../../contexts/narrowProvider"; import { useNarrow } from "../../contexts/narrowProvider";
import { CommunityData } from "../../models/CommunityData"; import { CommunityData } from "../../models/CommunityData";
import { Channel } from "../Channels/Channel"; import { Channel } from "../Channels/Channel";
import { EmptyChannel } from "../Channels/EmptyChannel";
import { Community } from "../Community"; import { Community } from "../Community";
import { ChannelMenu } from "../Form/ChannelMenu"; import { ChannelMenu } from "../Form/ChannelMenu";
import { MembersIcon } from "../Icons/MembersIcon"; import { MembersIcon } from "../Icons/MembersIcon";
@ -147,17 +146,14 @@ export function ChatBody({
<> <>
{!showChannelsList && !showMembersList && ( {!showChannelsList && !showMembersList && (
<> <>
{messages.length > 0 ? ( {messenger && community ? (
messenger && community ? ( <ChatMessages
<ChatMessages messages={messages}
messages={messages} activeChannelId={activeChannel.id}
activeChannelId={activeChannel.id} channel={activeChannel}
/> />
) : (
<LoadingSkeleton />
)
) : ( ) : (
<EmptyChannel channel={activeChannel} /> <LoadingSkeleton />
)} )}
<ChatInput /> <ChatInput />
</> </>

View File

@ -3,8 +3,10 @@ import styled from "styled-components";
import { useBlockedUsers } from "../../contexts/blockedUsersProvider"; import { useBlockedUsers } from "../../contexts/blockedUsersProvider";
import { useChatScrollHandle } from "../../hooks/useChatScrollHandle"; import { useChatScrollHandle } from "../../hooks/useChatScrollHandle";
import { ChannelData } from "../../models/ChannelData";
import { ChatMessage } from "../../models/ChatMessage"; import { ChatMessage } from "../../models/ChatMessage";
import { equalDate } from "../../utils"; import { equalDate } from "../../utils";
import { EmptyChannel } from "../Channels/EmptyChannel";
import { ContactMenu } from "../Form/ContactMenu"; import { ContactMenu } from "../Form/ContactMenu";
import { LoadingIcon } from "../Icons/LoadingIcon"; import { LoadingIcon } from "../Icons/LoadingIcon";
import { UserIcon } from "../Icons/UserIcon"; import { UserIcon } from "../Icons/UserIcon";
@ -71,9 +73,14 @@ function ChatUiMessage({
type ChatMessagesProps = { type ChatMessagesProps = {
messages: ChatMessage[]; messages: ChatMessage[];
activeChannelId: string; activeChannelId: string;
channel: ChannelData;
}; };
export function ChatMessages({ messages, activeChannelId }: ChatMessagesProps) { export function ChatMessages({
messages,
activeChannelId,
channel,
}: ChatMessagesProps) {
const ref = useRef<HTMLHeadingElement>(null); const ref = useRef<HTMLHeadingElement>(null);
const loadingMessages = useChatScrollHandle(messages, ref, activeChannelId); const loadingMessages = useChatScrollHandle(messages, ref, activeChannelId);
@ -93,6 +100,7 @@ export function ChatMessages({ messages, activeChannelId }: ChatMessagesProps) {
image={image} image={image}
/> />
<LinkModal isVisible={!!link} onClose={() => setLink("")} link={link} /> <LinkModal isVisible={!!link} onClose={() => setLink("")} link={link} />
<EmptyChannel channel={channel} />
{loadingMessages && ( {loadingMessages && (
<LoadingWrapper> <LoadingWrapper>
<LoadingIcon className="message" /> <LoadingIcon className="message" />