From 180b2be276b51bce8d7cb3ffd46b5d91fc167216 Mon Sep 17 00:00:00 2001 From: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:10:19 +0100 Subject: [PATCH] Add no community chat (#209) --- .../src/components/Chat/ChatCreation.tsx | 15 +- .../react-chat/src/components/ChatLoader.tsx | 36 ---- .../components/DappConnectCommunityChat.tsx | 28 +-- .../src/components/Form/IdentityLoader.tsx | 133 ------------- .../src/components/Members/MembersList.tsx | 48 ++--- .../src/contexts/messengerProvider.tsx | 3 +- .../contexts/userCreationStateProvider.tsx | 29 --- .../DappConnectGroupChat.tsx | 65 +++++++ .../src/groupChatComponents/GroupChat.tsx | 90 +++++++++ .../GroupChat/GroupChatBody.tsx | 182 ++++++++++++++++++ .../GroupMembers/GroupMembers.tsx | 49 +++++ .../src/hooks/messenger/useGroupChats.ts | 9 +- .../src/hooks/messenger/useLoadPrevDay.ts | 6 +- .../src/hooks/messenger/useMessenger.ts | 28 ++- .../src/hooks/useChatScrollHandle.ts | 6 +- packages/react-chat/src/index.ts | 10 +- .../react-group-chat-example/.eslintrc.json | 41 ++++ .../react-group-chat-example/.mocharc.json | 6 + .../react-group-chat-example/.prettierignore | 2 + packages/react-group-chat-example/README.md | 1 + .../react-group-chat-example/package.json | 71 +++++++ .../react-group-chat-example/src/_redirects | 1 + .../react-group-chat-example/src/index.html | 14 ++ .../react-group-chat-example/src/index.tsx | 139 +++++++++++++ .../react-group-chat-example/tsconfig.json | 47 +++++ .../tsconfig.tsbuildinfo | 1 + .../webpack.config.js | 88 +++++++++ yarn.lock | 54 ++++++ 28 files changed, 949 insertions(+), 253 deletions(-) delete mode 100644 packages/react-chat/src/components/ChatLoader.tsx delete mode 100644 packages/react-chat/src/components/Form/IdentityLoader.tsx delete mode 100644 packages/react-chat/src/contexts/userCreationStateProvider.tsx create mode 100644 packages/react-chat/src/groupChatComponents/DappConnectGroupChat.tsx create mode 100644 packages/react-chat/src/groupChatComponents/GroupChat.tsx create mode 100644 packages/react-chat/src/groupChatComponents/GroupChat/GroupChatBody.tsx create mode 100644 packages/react-chat/src/groupChatComponents/GroupMembers/GroupMembers.tsx create mode 100644 packages/react-group-chat-example/.eslintrc.json create mode 100644 packages/react-group-chat-example/.mocharc.json create mode 100644 packages/react-group-chat-example/.prettierignore create mode 100644 packages/react-group-chat-example/README.md create mode 100644 packages/react-group-chat-example/package.json create mode 100644 packages/react-group-chat-example/src/_redirects create mode 100644 packages/react-group-chat-example/src/index.html create mode 100644 packages/react-group-chat-example/src/index.tsx create mode 100644 packages/react-group-chat-example/tsconfig.json create mode 100644 packages/react-group-chat-example/tsconfig.tsbuildinfo create mode 100644 packages/react-group-chat-example/webpack.config.js diff --git a/packages/react-chat/src/components/Chat/ChatCreation.tsx b/packages/react-chat/src/components/Chat/ChatCreation.tsx index e80e16d..5a2bc9a 100644 --- a/packages/react-chat/src/components/Chat/ChatCreation.tsx +++ b/packages/react-chat/src/components/Chat/ChatCreation.tsx @@ -103,11 +103,6 @@ export function ChatCreation({ value={query} onInput={(e) => setQuery(e.currentTarget.value)} /> - )} {!narrow && styledGroup.length === 5 && ( @@ -132,12 +127,18 @@ export function ChatCreation({ Confirm {!narrow && } + - {!setEditGroup && !query && ( + {!setEditGroup && ( Contacts {identity && + !query && Object.values(contacts) .filter( (e) => @@ -181,7 +182,7 @@ const CreationBar = styled.div` display: flex; align-items: center; margin-bottom: 32px; - + position: relative; &.limit { align-items: flex-start; } diff --git a/packages/react-chat/src/components/ChatLoader.tsx b/packages/react-chat/src/components/ChatLoader.tsx deleted file mode 100644 index cd1a307..0000000 --- a/packages/react-chat/src/components/ChatLoader.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from "react"; - -import { ChatStateProvider } from "../contexts/chatStateProvider"; -import { IdentityProvider } from "../contexts/identityProvider"; -import { MessengerProvider } from "../contexts/messengerProvider"; -import { - UserCreationState, - useUserCreationState, -} from "../contexts/userCreationStateProvider"; - -import { Chat } from "./Chat"; -import { IdentityLoader } from "./Form/IdentityLoader"; - -type ChatLoaderProps = { - communityKey: string; -}; - -export function ChatLoader({ communityKey }: ChatLoaderProps) { - const [userCreationState] = useUserCreationState(); - - if (userCreationState === UserCreationState.NotCreating) - return ( - - - - - - - - ); - if (userCreationState === UserCreationState.Creating) { - return ; - } - - return null; -} diff --git a/packages/react-chat/src/components/DappConnectCommunityChat.tsx b/packages/react-chat/src/components/DappConnectCommunityChat.tsx index ec648ca..a80bf4e 100644 --- a/packages/react-chat/src/components/DappConnectCommunityChat.tsx +++ b/packages/react-chat/src/components/DappConnectCommunityChat.tsx @@ -4,17 +4,19 @@ import styled from "styled-components"; import { ConfigType } from ".."; import { ActivityProvider } from "../contexts/activityProvider"; +import { ChatStateProvider } from "../contexts/chatStateProvider"; import { ConfigProvider } from "../contexts/configProvider"; import { FetchMetadataProvider } from "../contexts/fetchMetadataProvider"; +import { IdentityProvider } from "../contexts/identityProvider"; +import { MessengerProvider } from "../contexts/messengerProvider"; import { ModalProvider } from "../contexts/modalProvider"; import { NarrowProvider } from "../contexts/narrowProvider"; import { ToastProvider } from "../contexts/toastProvider"; -import { UserCreationStateProvider } from "../contexts/userCreationStateProvider"; import { Metadata } from "../models/Metadata"; import { GlobalStyle } from "../styles/GlobalStyle"; import { Theme } from "../styles/themes"; -import { ChatLoader } from "./ChatLoader"; +import { Chat } from "./Chat"; interface DappConnectCommunityChatProps { theme: Theme; @@ -37,15 +39,19 @@ export function DappConnectCommunityChat({ - - - - - -