-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chat notif changes * added in-app chat notifs * fixed minor issue * fixed minor issue * fixed refetch * fixing stream * issue with duplicate stream event * fixed multiple connections * fixed multiple connections * Update config-dev.js * updated sdk verion * fixed gif * updated uiweb to 1.7.2 * fixed review comments
- Loading branch information
1 parent
b559c31
commit 66344c3
Showing
31 changed files
with
529 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FC } from 'react'; | ||
import { IconWrapper } from '../IconWrapper'; | ||
import { IconProps } from '../Icons.types'; | ||
|
||
const FillCircle: FC<IconProps> = (allProps) => { | ||
const { svgProps: props, ...restProps } = allProps; | ||
return ( | ||
<IconWrapper | ||
componentName="FillCircle" | ||
icon={ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="inherit" | ||
height="inherit" | ||
viewBox="0 0 20 20" | ||
fill="none" | ||
{...props} | ||
> | ||
<circle | ||
cx="10" | ||
cy="10" | ||
r="10" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
} | ||
{...restProps} | ||
/> | ||
); | ||
}; | ||
|
||
export default FillCircle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FC } from 'react'; | ||
import { IconWrapper } from '../IconWrapper'; | ||
import { IconProps } from '../Icons.types'; | ||
|
||
const Image: FC<IconProps> = (allProps) => { | ||
const { svgProps: props, ...restProps } = allProps; | ||
return ( | ||
<IconWrapper | ||
componentName="Image" | ||
icon={ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="inherit" | ||
height="inherit" | ||
viewBox="0 0 24 22" | ||
fill="none" | ||
{...props} | ||
> | ||
<path | ||
d="M15.2109 9.20528C15.97 9.20528 16.5854 8.58987 16.5854 7.83073C16.5854 7.07158 15.97 6.45618 15.2109 6.45618C14.4517 6.45618 13.8363 7.07158 13.8363 7.83073C13.8363 8.58987 14.4517 9.20528 15.2109 9.20528Z" | ||
fill="currentColor" | ||
/> | ||
<path | ||
d="M14.2155 15.1617L17.1581 12.2224C17.33 12.0507 17.563 11.9542 17.8059 11.9542C18.0488 11.9542 18.2818 12.0507 18.4537 12.2224L23 16.7722" | ||
stroke="currentColor" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
<path | ||
d="M1.0072 15.6989L7.23163 9.47329C7.31674 9.38809 7.41781 9.3205 7.52905 9.27438C7.6403 9.22827 7.75954 9.20453 7.87997 9.20453C8.00039 9.20453 8.11963 9.22827 8.23088 9.27438C8.34213 9.3205 8.44319 9.38809 8.5283 9.47329L19.2555 20.2017" | ||
stroke="currentColor" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
<rect | ||
x="1" | ||
y="1.79828" | ||
width="22" | ||
height="18.4034" | ||
rx="4" | ||
stroke="currentColor" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
</svg> | ||
} | ||
{...restProps} | ||
/> | ||
); | ||
}; | ||
|
||
export default Image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
import { FC, useContext } from 'react'; | ||
|
||
import { useNavigate } from 'react-router-dom'; | ||
import { css } from 'styled-components'; | ||
|
||
import { Box, Cross, Pin, Text, Image, FillCircle, ChatFilled, EditProfile } from 'blocks'; | ||
|
||
import { AppContextType } from 'types/context'; | ||
import { AppContext } from 'contexts/AppContext'; | ||
|
||
import { convertTimeStamp } from 'common/Common.utils'; | ||
import { shortenText } from 'helpers/UtilityHelper'; | ||
import { caip10ToWallet } from 'helpers/w2w'; | ||
|
||
import { useResolveWeb3Name } from 'hooks/useResolveWeb3Name'; | ||
import { useGetGroupInfo, useGetUserProfileDetails } from 'queries'; | ||
|
||
type InAppChatNotificationsProps = { | ||
chatDetails: Array<any>; | ||
onClose: () => void; | ||
}; | ||
|
||
const getContentText = (chatDetail: any) => { | ||
if (chatDetail.message.type === 'Text') return chatDetail.message.content; | ||
if (chatDetail.message.type === 'Image') return 'Image'; | ||
if (chatDetail.message.type === 'File') return 'File'; | ||
if (chatDetail.message.type === 'MediaEmbed' || chatDetail.message.type === 'GIF') return 'GIF'; | ||
}; | ||
const getContentImage = (chatDetail: any) => { | ||
if ( | ||
chatDetail.message.type === 'Image' || | ||
chatDetail.message.type === 'MediaEmbed' || | ||
chatDetail.message.type === 'GIF' | ||
) | ||
return ( | ||
<Image | ||
size={16} | ||
color="icon-tertiary" | ||
/> | ||
); | ||
if (chatDetail.message.type === 'File') | ||
return ( | ||
<Pin | ||
size={16} | ||
color="icon-tertiary" | ||
/> | ||
); | ||
}; | ||
|
||
const InAppChatNotifications: FC<InAppChatNotificationsProps> = ({ chatDetails, onClose }) => { | ||
const { web3NameList }: AppContextType = useContext(AppContext)!; | ||
const fromAddress = caip10ToWallet(chatDetails[0]?.from); | ||
const { data: userProfileDetails } = useGetUserProfileDetails(fromAddress, { | ||
refetchOnWindowFocus: false, | ||
staleTime: Infinity, | ||
refetchInterval: 3600000, // 1 hour, | ||
}); | ||
const { data: groupInfo } = useGetGroupInfo(chatDetails[0]?.meta?.group ? chatDetails[0].chatId : '', { | ||
refetchOnWindowFocus: false, | ||
staleTime: Infinity, | ||
refetchInterval: 3600000, // 1 hour, | ||
}); | ||
|
||
const navigate = useNavigate(); | ||
|
||
useResolveWeb3Name(fromAddress); | ||
const web3Name = web3NameList[fromAddress]; | ||
const sender = web3Name ? web3Name : shortenText(fromAddress, 6); | ||
const displayName = chatDetails[0]?.meta?.group | ||
? groupInfo?.groupName || shortenText(chatDetails[0]?.chatId, 6) | ||
: web3Name || shortenText(fromAddress, 6); | ||
|
||
const latestTimestamp = convertTimeStamp(chatDetails[chatDetails.length - 1]?.timestamp); | ||
|
||
//optimise it and fix the close button z-index | ||
return ( | ||
<Box | ||
width="397px" | ||
display="flex" | ||
> | ||
{chatDetails && userProfileDetails && ( | ||
<Box | ||
padding="spacing-sm" | ||
display="flex" | ||
borderRadius="radius-sm" | ||
flexDirection="column" | ||
gap="spacing-xxs" | ||
border="border-sm solid stroke-tertiary" | ||
backgroundColor="surface-primary" | ||
width="inherit" | ||
cursor="pointer" | ||
onClick={() => navigate(`/chat/chatid:${chatDetails[0].chatId}`)} | ||
> | ||
<Box | ||
display="flex" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Box | ||
display="flex" | ||
gap="spacing-xxs" | ||
alignItems="center" | ||
> | ||
<Box | ||
width="24px" | ||
height="24px" | ||
overflow="hidden" | ||
borderRadius="radius-round" | ||
css={css` | ||
flex-shrink: 0; | ||
`} | ||
> | ||
{chatDetails[0].event === 'chat.request' ? ( | ||
<ChatFilled | ||
size={24} | ||
color="icon-brand-medium" | ||
/> | ||
) : ( | ||
<img | ||
width="100%" | ||
height="100%" | ||
src={userProfileDetails?.picture || groupInfo?.groupImage || ''} | ||
alt={displayName} | ||
/> | ||
)} | ||
</Box> | ||
<Text | ||
color="text-primary" | ||
variant="bes-semibold" | ||
> | ||
{chatDetails[0].event === 'chat.request' ? 'Push Chat' : displayName} | ||
</Text> | ||
<FillCircle | ||
color="icon-tertiary" | ||
size={4} | ||
/> | ||
<Text | ||
color="text-tertiary" | ||
variant="c-semibold" | ||
> | ||
{latestTimestamp} | ||
</Text> | ||
</Box> | ||
<Box | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
onClose(); | ||
}} | ||
cursor="pointer" | ||
> | ||
<Cross | ||
color="icon-primary" | ||
size={16} | ||
/> | ||
</Box> | ||
</Box> | ||
{chatDetails.map((chatDetail: any) => | ||
chatDetail.event === 'chat.request' ? ( | ||
<Box | ||
display="flex" | ||
gap="spacing-xxxs" | ||
alignItems="center" | ||
> | ||
<EditProfile | ||
size={16} | ||
color="icon-tertiary" | ||
/> | ||
<Box> | ||
<Text | ||
color="text-primary" | ||
variant="bes-bold" | ||
as="span" | ||
> | ||
{displayName}{' '} | ||
</Text> | ||
<Text | ||
color="text-secondary" | ||
variant="bes-regular" | ||
as="span" | ||
> | ||
has sent you a chat request | ||
</Text> | ||
</Box> | ||
</Box> | ||
) : ( | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
> | ||
<Box | ||
display="flex" | ||
gap="spacing-xxxs" | ||
alignItems="center" | ||
> | ||
{chatDetails[0]?.meta?.group && ( | ||
<Text | ||
color="text-primary" | ||
variant="bes-bold" | ||
as="span" | ||
> | ||
{sender}{' '} | ||
</Text> | ||
)} | ||
{chatDetail.message.type !== 'Text' ? <Box>{getContentImage(chatDetail)}</Box> : null} | ||
<Text | ||
color="text-secondary" | ||
variant="bes-regular" | ||
numberOfLines={2} | ||
> | ||
{getContentText(chatDetail)} | ||
</Text> | ||
</Box> | ||
</Box> | ||
) | ||
)} | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export { InAppChatNotifications }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.