From 5d3926779ff55c1f7fd76d8db3970ca66e2a6f05 Mon Sep 17 00:00:00 2001 From: Pavel <14926950+prichodko@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:20:23 +0100 Subject: [PATCH] Update @status-im/react exports (#235) * Move Community to modules folder * Move Channel to modules folder * Remove fetch metadata provider * Update index file extension --- examples/channel/index.tsx | 4 +- examples/community/index.tsx | 4 +- packages/status-react/package.json | 2 +- .../components/Chat/ChatMessageContent.tsx | 34 +++++----- .../src/components/Chat/ChatTopbar.tsx | 4 +- .../src/components/CommunityChat.tsx | 67 ------------------- .../src/contexts/fetchMetadataProvider.tsx | 27 -------- .../src/groupChatComponents/GroupChat.tsx | 58 ---------------- packages/status-react/src/index.ts | 4 -- packages/status-react/src/index.tsx | 4 ++ .../channel}/GroupChat/GroupChatBody.tsx | 24 +++---- .../channel}/GroupChatRoom.tsx | 35 +++++----- .../channel}/GroupMembers/GroupMembers.tsx | 4 +- .../src/modules/channel/index.tsx | 60 +++++++++++++++++ .../community}/CommunityChatRoom.tsx | 47 ++++++------- .../community/CommunitySidebar.tsx} | 12 ++-- .../src/modules/community/index.tsx | 63 +++++++++++++++++ 17 files changed, 212 insertions(+), 241 deletions(-) delete mode 100644 packages/status-react/src/components/CommunityChat.tsx delete mode 100644 packages/status-react/src/contexts/fetchMetadataProvider.tsx delete mode 100644 packages/status-react/src/groupChatComponents/GroupChat.tsx delete mode 100644 packages/status-react/src/index.ts create mode 100644 packages/status-react/src/index.tsx rename packages/status-react/src/{groupChatComponents => modules/channel}/GroupChat/GroupChatBody.tsx (84%) rename packages/status-react/src/{groupChatComponents => modules/channel}/GroupChatRoom.tsx (59%) rename packages/status-react/src/{groupChatComponents => modules/channel}/GroupMembers/GroupMembers.tsx (90%) create mode 100644 packages/status-react/src/modules/channel/index.tsx rename packages/status-react/src/{components => modules/community}/CommunityChatRoom.tsx (54%) rename packages/status-react/src/{components/Community.tsx => modules/community/CommunitySidebar.tsx} (58%) create mode 100644 packages/status-react/src/modules/community/index.tsx diff --git a/examples/channel/index.tsx b/examples/channel/index.tsx index 165c1524..335d3a87 100644 --- a/examples/channel/index.tsx +++ b/examples/channel/index.tsx @@ -1,12 +1,12 @@ import React, { StrictMode } from 'react' import { render } from 'react-dom' -import { GroupChat, lightTheme } from '@status-im/react' +import { Channel, lightTheme } from '@status-im/react' const App = () => { return (
- { return (
- message, [message]) const [elements, setElements] = useState<(string | React.ReactElement)[]>([ content, ]) const [link, setLink] = useState(undefined) - const [openGraph, setOpenGraph] = useState(undefined) + const [openGraph] = useState(undefined) useEffect(() => { let link @@ -95,21 +93,21 @@ export function ChatMessageContent({ setElements(newSplit) }, [content, setLink, setMentioned, setElements, setLinkOpen]) - useEffect(() => { - const updatePreview = async () => { - if (link && fetchMetadata) { - try { - const metadata = await fetchMetadata(link) - if (metadata) { - setOpenGraph(metadata) - } - } catch { - return - } - } - } - updatePreview() - }, [link, fetchMetadata]) + // useEffect(() => { + // const updatePreview = async () => { + // if (link && fetchMetadata) { + // try { + // const metadata = await fetchMetadata(link) + // if (metadata) { + // setOpenGraph(metadata) + // } + // } catch { + // return + // } + // } + // } + // updatePreview() + // }, [link, fetchMetadata]) return ( diff --git a/packages/status-react/src/components/Chat/ChatTopbar.tsx b/packages/status-react/src/components/Chat/ChatTopbar.tsx index 586fe563..3565c8c2 100644 --- a/packages/status-react/src/components/Chat/ChatTopbar.tsx +++ b/packages/status-react/src/components/Chat/ChatTopbar.tsx @@ -5,12 +5,12 @@ import styled from 'styled-components' import { useMessengerContext } from '../../contexts/messengerProvider' import { useNarrow } from '../../contexts/narrowProvider' import { useClickOutside } from '../../hooks/useClickOutside' +import { CommunitySidebar } from '../../modules/community/CommunitySidebar' import { ActivityButton, ActivityWrapper, } from '../ActivityCenter/ActivityButton' import { Channel } from '../Channels/Channel' -import { Community } from '../Community' import { ChannelMenu } from '../Form/ChannelMenu' import { ActivityIcon } from '../Icons/ActivityIcon' import { MembersIcon } from '../Icons/MembersIcon' @@ -85,7 +85,7 @@ export function ChatTopbar({ <> {narrow && ( - + )} diff --git a/packages/status-react/src/components/CommunityChat.tsx b/packages/status-react/src/components/CommunityChat.tsx deleted file mode 100644 index e1dd549b..00000000 --- a/packages/status-react/src/components/CommunityChat.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useRef } from 'react' - -import styled, { ThemeProvider } from 'styled-components' - -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 { ScrollProvider } from '../contexts/scrollProvider' -import { ToastProvider } from '../contexts/toastProvider' -import { GlobalStyle } from '../styles/GlobalStyle' -import { CommunityChatRoom } from './CommunityChatRoom' - -import type { ConfigType } from '..' -import type { Metadata } from '../models/Metadata' -import type { Theme } from '../styles/themes' - -interface CommunityChatProps { - theme: Theme - communityKey: string - config: ConfigType - fetchMetadata?: (url: string) => Promise -} - -export function CommunityChat({ - theme, - config, - fetchMetadata, - communityKey, -}: CommunityChatProps) { - const ref = useRef(null) - return ( - - - - - - - - - - - - - -