From e7cfd26b1b0efa0fe3d45337a1379b150ede14be Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Wed, 2 Mar 2022 20:15:11 +0300 Subject: [PATCH] fix: mobile chat layout --- src/components/Chat/Sidebar/Sidebar.tsx | 8 +------- src/components/Chat/Sidebar/Users/User/Info.tsx | 6 +++--- src/components/Chat/Window/Message/Avatar.tsx | 2 +- src/components/Chat/Window/Message/Text.tsx | 2 +- src/components/Chat/Window/Window.tsx | 3 +-- src/pages/main/main.tsx | 4 +++- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/Chat/Sidebar/Sidebar.tsx b/src/components/Chat/Sidebar/Sidebar.tsx index 202cb36..0537fb8 100644 --- a/src/components/Chat/Sidebar/Sidebar.tsx +++ b/src/components/Chat/Sidebar/Sidebar.tsx @@ -10,13 +10,7 @@ export interface ISidebarComposition { const Sidebar: React.FC & ISidebarComposition = props => { return ( - + {props.children} ); diff --git a/src/components/Chat/Sidebar/Users/User/Info.tsx b/src/components/Chat/Sidebar/Users/User/Info.tsx index 66a6d35..913eb00 100644 --- a/src/components/Chat/Sidebar/Users/User/Info.tsx +++ b/src/components/Chat/Sidebar/Users/User/Info.tsx @@ -16,12 +16,12 @@ const Info: React.FC = ({ fullname, lastMessage }) => { return ( - + {isMe ? 'Favorites' : fullname}
{lastMessage && ( - + {lastMessage.from === me?.id && `You: `} - {lastMessage.content} + {lastMessage.content.length >= 20 ? lastMessage.content.slice(0, 20 - 1) + '...' : lastMessage.content} )} diff --git a/src/components/Chat/Window/Message/Avatar.tsx b/src/components/Chat/Window/Message/Avatar.tsx index 6887fe1..85cad6d 100644 --- a/src/components/Chat/Window/Message/Avatar.tsx +++ b/src/components/Chat/Window/Message/Avatar.tsx @@ -7,7 +7,7 @@ export interface IAvatarProps { const Avatar: React.FC = memo(({ fullname: name }) => { return ( - + ); diff --git a/src/components/Chat/Window/Message/Text.tsx b/src/components/Chat/Window/Message/Text.tsx index 14e4bad..714b11e 100644 --- a/src/components/Chat/Window/Message/Text.tsx +++ b/src/components/Chat/Window/Message/Text.tsx @@ -14,7 +14,7 @@ const Text: React.FC = ({ content, time }) => { return ( - + {content} = props => ( - + {props.children} ); @@ -192,7 +192,6 @@ const Window: React.FC = props => { resize={'block'} type='text' placeholder='Write a message...' - maxW='900px' variant={'outline'} rounded='xl' mr='2' diff --git a/src/pages/main/main.tsx b/src/pages/main/main.tsx index ee6be1c..8dfc173 100644 --- a/src/pages/main/main.tsx +++ b/src/pages/main/main.tsx @@ -40,6 +40,8 @@ const MainPage: React.FC = () => { if (me === null || courses === null || stat === null) return ; + const unreadMessages = me.notifications.filter(n => n.type === 'MESSAGE'); + return ( @@ -58,7 +60,7 @@ const MainPage: React.FC = () => { - 0 + {unreadMessages.length}