From eb82130a0fef6cae418d03c303bec55146a2ef16 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 28 Oct 2024 11:38:33 +0530 Subject: [PATCH 01/14] chat notif changes --- src/blocks/icons/components/FillCircle.tsx | 32 +++ src/blocks/icons/components/Image.tsx | 55 ++++++ src/blocks/icons/index.ts | 2 + src/common/Common.utils.tsx | 17 ++ .../components/InAppChatNotifications.tsx | 184 ++++++++++++++++++ src/common/components/index.ts | 1 + src/common/hooks/useInAppNotifications.tsx | 55 ++++-- src/queries/hooks/user/index.ts | 1 + .../hooks/user/useGetProfileDetails.ts | 29 +++ .../user/getUserProfileDetailsModelCreator.ts | 5 + src/queries/models/user/index.ts | 1 + src/queries/queryKeys.ts | 1 + .../services/user/getUserProfileDetails.ts | 5 + src/queries/services/user/index.ts | 1 + src/queries/types/user.ts | 8 + 15 files changed, 386 insertions(+), 11 deletions(-) create mode 100644 src/blocks/icons/components/FillCircle.tsx create mode 100644 src/blocks/icons/components/Image.tsx create mode 100644 src/common/components/InAppChatNotifications.tsx create mode 100644 src/queries/hooks/user/useGetProfileDetails.ts create mode 100644 src/queries/models/user/getUserProfileDetailsModelCreator.ts create mode 100644 src/queries/services/user/getUserProfileDetails.ts diff --git a/src/blocks/icons/components/FillCircle.tsx b/src/blocks/icons/components/FillCircle.tsx new file mode 100644 index 0000000000..271e50b978 --- /dev/null +++ b/src/blocks/icons/components/FillCircle.tsx @@ -0,0 +1,32 @@ +import { FC } from 'react'; +import { IconWrapper } from '../IconWrapper'; +import { IconProps } from '../Icons.types'; + +const FillCircle: FC = (allProps) => { + const { svgProps: props, ...restProps } = allProps; + return ( + + + + } + {...restProps} + /> + ); +}; + +export default FillCircle; diff --git a/src/blocks/icons/components/Image.tsx b/src/blocks/icons/components/Image.tsx new file mode 100644 index 0000000000..b89b65265f --- /dev/null +++ b/src/blocks/icons/components/Image.tsx @@ -0,0 +1,55 @@ +import { FC } from 'react'; +import { IconWrapper } from '../IconWrapper'; +import { IconProps } from '../Icons.types'; + +const Image: FC = (allProps) => { + const { svgProps: props, ...restProps } = allProps; + return ( + + + + + + + } + {...restProps} + /> + ); +}; + +export default Image; diff --git a/src/blocks/icons/index.ts b/src/blocks/icons/index.ts index 089304d5b5..9b49da2f6b 100644 --- a/src/blocks/icons/index.ts +++ b/src/blocks/icons/index.ts @@ -70,10 +70,12 @@ export { default as ErrorFilled } from './components/ErrorFilled'; export { default as ExternalLink } from './components/ExternalLink'; export { default as Front } from './components/Front'; +export { default as FillCircle } from './components/FillCircle'; export { default as Gif } from './components/Gif'; export { default as InfoFilled } from './components/InfoFilled'; +export { default as Image } from './components/Image'; export { default as Governance } from './components/Governance'; export { default as GovernanceFilled } from './components/GovernanceFilled'; diff --git a/src/common/Common.utils.tsx b/src/common/Common.utils.tsx index ea6c7b8c83..7b33acc08f 100644 --- a/src/common/Common.utils.tsx +++ b/src/common/Common.utils.tsx @@ -2,6 +2,7 @@ import { appConfig } from 'config'; import { LOGO_ALIAS_CHAIN } from './Common.constants'; import { networkName } from 'helpers/UtilityHelper'; import { EnvType } from './Common.types'; +import moment from 'moment'; export const allowedNetworks = appConfig.allowedNetworks.filter( (chain: number) => chain != appConfig.coreContractChain @@ -53,3 +54,19 @@ export const isValidURL = (str: string | undefined) => { export const getCurrentEnv = (): EnvType => { return appConfig.appEnv; }; + +export function convertTimeStamp(timestamp: string) { + const date = moment.unix(Number(timestamp)); + const now = moment(); + + const diffInSeconds = now.diff(date, 'seconds'); + const diffInMinutes = now.diff(date, 'minutes'); + + if (diffInSeconds < 60) { + return 'now'; + } else if (diffInMinutes < 60) { + return `${diffInMinutes} minutes ago`; + } else { + return date.format('hh:mm A'); + } +} diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx new file mode 100644 index 0000000000..5fa7181fb3 --- /dev/null +++ b/src/common/components/InAppChatNotifications.tsx @@ -0,0 +1,184 @@ +import { Box, Cross, Link, Pin, Text, notification, Image, Ellipse, FillCircle, ChatFilled, EditProfile } from 'blocks'; +import { convertTimeStamp } from 'common/Common.utils'; +import { AppContext } from 'contexts/AppContext'; +import { shortenText } from 'helpers/UtilityHelper'; +import { caip10ToWallet } from 'helpers/w2w'; +import { useResolveWeb3Name } from 'hooks/useResolveWeb3Name'; +import { useGetUserProfileDetails } from 'queries'; + +import { FC, useContext } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { css } from 'styled-components'; +import { AppContextType } from 'types/context'; + +type InAppChatNotificationsProps = { + chatDetails: any; +}; + +//setSelectedChatId +//emoji +const InAppChatNotifications: FC = ({ chatDetails }) => { + console.debug(chatDetails, 'chatDetails'); + const { web3NameList }: AppContextType = useContext(AppContext)!; + const fromAddress = caip10ToWallet(chatDetails?.from); + const { data: userProfileDetails } = useGetUserProfileDetails(fromAddress); + const navigate = useNavigate(); + console.debug(chatDetails?.from, userProfileDetails, 'userProfile'); + useResolveWeb3Name(fromAddress); + const web3Name = web3NameList[fromAddress]; + const displayName = web3Name ? web3Name : shortenText(fromAddress, 6); + + const getContentText = () => { + if (chatDetails.message.type === 'Text') return chatDetails.message.content; + if (chatDetails.message.type === 'Image') return 'Image'; + if (chatDetails.message.type === 'File') return 'File'; + if (chatDetails.message.type === 'GIF') return 'GIF'; + }; + const getContentImage = () => { + if (chatDetails.message.type === 'Image' || chatDetails.message.type === 'GIF') + return ( + + ); + if (chatDetails.message.type === 'File') + return ( + + ); + }; + + return ( + + {chatDetails && userProfileDetails && ( + navigate(`/chat/chatid:${chatDetails.chatId}`)} + > + + + + {chatDetails.event === 'chat.request' ? ( + + ) : ( + {userProfileDetails?.name + )} + + + {chatDetails.event === 'chat.request' ? 'Push Chat' : displayName} + + + + {convertTimeStamp(chatDetails?.timestamp)} + + + notification.hide()} + cursor="pointer" + > + + + + {chatDetails.event === 'chat.request' ? ( + + + + + {displayName}{' '} + + + has sent you a chat request + + + + ) : ( + + + {chatDetails.message.type !== 'Text' ? {getContentImage()} : null} + + {getContentText()} + + + + )} + + )} + + ); +}; + +export { InAppChatNotifications }; diff --git a/src/common/components/index.ts b/src/common/components/index.ts index 465df82dad..4b5412cac5 100644 --- a/src/common/components/index.ts +++ b/src/common/components/index.ts @@ -9,3 +9,4 @@ export * from './TokenFaucet'; export * from './CopyButton'; export * from './VerifiedChannelTooltipContent'; export * from './InAppChannelNotifications'; +export * from './InAppChatNotifications'; diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index 592b596648..e5a1b5f9d6 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -1,15 +1,17 @@ -import { useEffect, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { CONSTANTS, NotificationEvent } from '@pushprotocol/restapi'; import { useSelector } from 'react-redux'; import { deviceSizes, notification } from 'blocks'; -import { InAppChannelNotifications } from 'common'; +import { InAppChannelNotifications, InAppChatNotifications } from 'common'; import { useDeviceWidthCheck } from 'hooks'; +import { Context } from 'modules/chat/ChatModule'; export const useInAppNotifications = () => { const [isStreamConnected, setIsStreamConnected] = useState(false); + // const { setSelectedChatId } = useContext(Context); const isMobile = useDeviceWidthCheck(parseInt(deviceSizes.mobileL)); const { userPushSDKInstance } = useSelector((state: any) => { return state.user; @@ -40,16 +42,47 @@ export const useInAppNotifications = () => { userPushSDKInstance, userPushSDKInstance?.uid, userPushSDKInstance?.stream?.uid, - userPushSDKInstance?.stream + userPushSDKInstance?.stream, + data + ); + if (data.source !== 'PUSH_CHAT') + notification.show({ + overlay: , + position: isMobile ? 'top-center' : 'bottom-right', + duration: 5000, + onClick: () => { + notification.hide(); + }, + }); + }); + userPushSDKInstance?.stream?.on(CONSTANTS.STREAM.CHAT, (data: any) => { + console.debug( + 'src::common::hooks::useStream::attachListeners::CHAT::', + userPushSDKInstance?.uid, + userPushSDKInstance?.stream?.uid, + userPushSDKInstance?.stream, + data ); - notification.show({ - overlay: , - position: isMobile ? 'top-center' : 'bottom-right', - duration: 5000, - onClick: () => { - notification.hide(); - }, - }); + + if (data.event === 'chat.message' || data.event === 'chat.request') { + if (data.origin === 'other') + notification.show({ + overlay: , + position: isMobile ? 'top-center' : 'bottom-right', + duration: 5000, + // onClose: () => { + // notification.hide(); + // }, + onClick: () => { + notification.hide(); + }, + }); + } + + //attached image text + + //group + //stacking }); }; diff --git a/src/queries/hooks/user/index.ts b/src/queries/hooks/user/index.ts index fe7160ed77..72fcb30fd9 100644 --- a/src/queries/hooks/user/index.ts +++ b/src/queries/hooks/user/index.ts @@ -2,3 +2,4 @@ export * from './useGetUserSubscriptions'; export * from './useSubscribeChannel'; export * from './useUnsubscribeChannel'; export * from './useUpdateNotificationSettings'; +export * from './useGetProfileDetails'; diff --git a/src/queries/hooks/user/useGetProfileDetails.ts b/src/queries/hooks/user/useGetProfileDetails.ts new file mode 100644 index 0000000000..a583bd85b5 --- /dev/null +++ b/src/queries/hooks/user/useGetProfileDetails.ts @@ -0,0 +1,29 @@ +import { useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { useSelector } from 'react-redux'; + +import { userProfileDetails } from '../../queryKeys'; +import { getUserProfileDetails } from '../../services'; + +//Types +import { UserStoreType } from 'types'; +import { UserProfileDetailsResponse } from '../../types'; + +/** + * @param userAddress + * @returns query response + */ +export const useGetUserProfileDetails = ( + userAddress?: string, + config?: Partial> +) => { + const { userPushSDKInstance } = useSelector((state: UserStoreType) => { + return state.user; + }); + + const query = useQuery({ + queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress || null], + queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress), + ...config, + }); + return query; +}; diff --git a/src/queries/models/user/getUserProfileDetailsModelCreator.ts b/src/queries/models/user/getUserProfileDetailsModelCreator.ts new file mode 100644 index 0000000000..c44fc6bf87 --- /dev/null +++ b/src/queries/models/user/getUserProfileDetailsModelCreator.ts @@ -0,0 +1,5 @@ +import { UserProfileDetailsResponse } from '../../types'; + +//any remodelling needed in the response can be done here +export const getUserProfileDetailsModelCreator = (response: UserProfileDetailsResponse): UserProfileDetailsResponse => + response; diff --git a/src/queries/models/user/index.ts b/src/queries/models/user/index.ts index ea78fdbc11..ce1d94afca 100644 --- a/src/queries/models/user/index.ts +++ b/src/queries/models/user/index.ts @@ -1 +1,2 @@ export * from './getUserSubscriptionsModelCreator'; +export * from './getUserProfileDetailsModelCreator'; diff --git a/src/queries/queryKeys.ts b/src/queries/queryKeys.ts index 0270b2b84d..7740110586 100644 --- a/src/queries/queryKeys.ts +++ b/src/queries/queryKeys.ts @@ -45,4 +45,5 @@ export const userRewardsDetails = 'userRewardsDetails'; export const UserRewardsDetails = 'userRewardsDetails'; export const userSubscription = 'userSubscription'; export const userTwitterDetails = 'userTwitterDetails'; +export const userProfileDetails = 'userProfileDetails'; export const verifyAliasChain = 'verifyAliasChain'; diff --git a/src/queries/services/user/getUserProfileDetails.ts b/src/queries/services/user/getUserProfileDetails.ts new file mode 100644 index 0000000000..77759ae14b --- /dev/null +++ b/src/queries/services/user/getUserProfileDetails.ts @@ -0,0 +1,5 @@ +import { PushAPI } from '@pushprotocol/restapi'; +import { getUserProfileDetailsModelCreator } from 'queries/models'; + +export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address?: string) => + userPushSDKInstance.profile.info({ overrideAccount: address }).then(getUserProfileDetailsModelCreator); diff --git a/src/queries/services/user/index.ts b/src/queries/services/user/index.ts index 6618895a84..da46eb1d04 100644 --- a/src/queries/services/user/index.ts +++ b/src/queries/services/user/index.ts @@ -2,3 +2,4 @@ export * from './getUserSubscriptions'; export * from './subscribeToChannel'; export * from './unsubscribeChannel'; export * from './updateNotificationSettings'; +export * from './getUserProfileDetails'; diff --git a/src/queries/types/user.ts b/src/queries/types/user.ts index dbdf8eec16..209d773ce9 100644 --- a/src/queries/types/user.ts +++ b/src/queries/types/user.ts @@ -32,3 +32,11 @@ export type UnsubscribeChannelResponse = { status: string; message: string; }; + +export type UserProfileDetailsResponse = { + blockedUsersList: Array; + desc: string | null; + name: string | null; + picture: string; + profileVerificationProof: string | null; +}; From 80b3b9266d31f3c3c92b63e269a048c1f12e53fa Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 29 Oct 2024 15:28:40 +0530 Subject: [PATCH 02/14] added in-app chat notifs --- src/blocks/notification/Notification.tsx | 23 ++- src/blocks/notification/Notification.types.ts | 2 + .../components/InAppChatNotifications.tsx | 166 ++++++++++-------- src/common/hooks/useInAppNotifications.tsx | 54 ++++-- src/queries/hooks/chat/index.ts | 1 + src/queries/hooks/chat/useGetGroupInfo.ts | 26 +++ src/queries/hooks/index.ts | 1 + .../hooks/user/useGetProfileDetails.ts | 1 - .../models/chat/getGroupInfoModelCreator.ts | 4 + src/queries/models/chat/index.ts | 1 + src/queries/models/index.ts | 1 + src/queries/services/chat/getGroupInfo.ts | 5 + src/queries/services/chat/index.ts | 1 + src/queries/services/index.ts | 1 + src/queries/types/chat.ts | 3 + src/queries/types/index.ts | 1 + 16 files changed, 196 insertions(+), 95 deletions(-) create mode 100644 src/queries/hooks/chat/index.ts create mode 100644 src/queries/hooks/chat/useGetGroupInfo.ts create mode 100644 src/queries/models/chat/getGroupInfoModelCreator.ts create mode 100644 src/queries/models/chat/index.ts create mode 100644 src/queries/services/chat/getGroupInfo.ts create mode 100644 src/queries/services/chat/index.ts create mode 100644 src/queries/types/chat.ts diff --git a/src/blocks/notification/Notification.tsx b/src/blocks/notification/Notification.tsx index 9750a8f66a..cede0c0d6e 100644 --- a/src/blocks/notification/Notification.tsx +++ b/src/blocks/notification/Notification.tsx @@ -116,12 +116,23 @@ const toastIds: Array = []; // Export the notification object with show and hide methods const notification = { - show: (config: NotificationProps) => { - const toastId = toast.custom(() => , { - duration: config.duration || Infinity, - position: config.position || 'bottom-right', - }); - toastIds.push(toastId); + show: (config: NotificationProps, id?: string) => { + if (toastIds.find((toastId) => toastId === id)) { + toast.custom(() => , { + id: id, + duration: config.duration || Infinity, + position: config.position || 'bottom-right', + onAutoClose: config.onAutoClose, + }); + } else { + const toastId = toast.custom(() => , { + id: id, + duration: config.duration || Infinity, + position: config.position || 'bottom-right', + onAutoClose: config.onAutoClose, + }); + toastIds.push(toastId); + } }, hide: () => { if (toastIds.length > 0) { diff --git a/src/blocks/notification/Notification.types.ts b/src/blocks/notification/Notification.types.ts index 924f78109a..313bd31f02 100644 --- a/src/blocks/notification/Notification.types.ts +++ b/src/blocks/notification/Notification.types.ts @@ -16,4 +16,6 @@ export type NotificationProps = { position?: 'bottom-right' | 'bottom-left' | 'top-center'; /* Optional duration of the notification component */ duration?: number; + /* Optional onAutoClose event for the notification called after it's timeout */ + onAutoClose?: () => void; }; diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index 5fa7181fb3..0c8f9ce2cb 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -1,48 +1,57 @@ -import { Box, Cross, Link, Pin, Text, notification, Image, Ellipse, FillCircle, ChatFilled, EditProfile } from 'blocks'; -import { convertTimeStamp } from 'common/Common.utils'; -import { AppContext } from 'contexts/AppContext'; -import { shortenText } from 'helpers/UtilityHelper'; -import { caip10ToWallet } from 'helpers/w2w'; -import { useResolveWeb3Name } from 'hooks/useResolveWeb3Name'; -import { useGetUserProfileDetails } from 'queries'; - 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: any; + chatDetails: Array; + onClose: () => void; }; -//setSelectedChatId -//emoji -const InAppChatNotifications: FC = ({ chatDetails }) => { - console.debug(chatDetails, 'chatDetails'); +const InAppChatNotifications: FC = ({ chatDetails, onClose }) => { const { web3NameList }: AppContextType = useContext(AppContext)!; - const fromAddress = caip10ToWallet(chatDetails?.from); + const fromAddress = caip10ToWallet(chatDetails[0]?.from); const { data: userProfileDetails } = useGetUserProfileDetails(fromAddress); + const { data: groupInfo } = useGetGroupInfo(chatDetails[0]?.meta?.group ? chatDetails[0].chatId : ''); + const navigate = useNavigate(); - console.debug(chatDetails?.from, userProfileDetails, 'userProfile'); + useResolveWeb3Name(fromAddress); const web3Name = web3NameList[fromAddress]; - const displayName = web3Name ? web3Name : shortenText(fromAddress, 6); + 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); - const getContentText = () => { - if (chatDetails.message.type === 'Text') return chatDetails.message.content; - if (chatDetails.message.type === 'Image') return 'Image'; - if (chatDetails.message.type === 'File') return 'File'; - if (chatDetails.message.type === 'GIF') return 'GIF'; + 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 === 'GIF') return 'GIF'; }; - const getContentImage = () => { - if (chatDetails.message.type === 'Image' || chatDetails.message.type === 'GIF') + const getContentImage = (chatDetail: any) => { + if (chatDetail.message.type === 'Image' || chatDetail.message.type === 'GIF') return ( ); - if (chatDetails.message.type === 'File') + if (chatDetail.message.type === 'File') return ( = ({ chatDetails } ); }; + //optimise it and fix the close button z-index return ( = ({ chatDetails } backgroundColor="surface-primary" width="inherit" cursor="pointer" - onClick={() => navigate(`/chat/chatid:${chatDetails.chatId}`)} + onClick={() => navigate(`/chat/chatid:${chatDetails[0].chatId}`)} > = ({ chatDetails } flex-shrink: 0; `} > - {chatDetails.event === 'chat.request' ? ( + {chatDetails[0].event === 'chat.request' ? ( ) : ( {userProfileDetails?.name )} @@ -104,7 +114,7 @@ const InAppChatNotifications: FC = ({ chatDetails } color="text-primary" variant="bes-semibold" > - {chatDetails.event === 'chat.request' ? 'Push Chat' : displayName} + {chatDetails[0].event === 'chat.request' ? 'Push Chat' : displayName} = ({ chatDetails } color="text-tertiary" variant="c-semibold" > - {convertTimeStamp(chatDetails?.timestamp)} + {latestTimestamp} notification.hide()} + onClick={(e) => { + e.stopPropagation(); + onClose(); + }} cursor="pointer" > = ({ chatDetails } /> - {chatDetails.event === 'chat.request' ? ( - - - - - {displayName}{' '} - - - has sent you a chat request - - - - ) : ( - + {chatDetails.map((chatDetail: any) => + chatDetail.event === 'chat.request' ? ( - {chatDetails.message.type !== 'Text' ? {getContentImage()} : null} - + + + {displayName}{' '} + + + has sent you a chat request + + + + ) : ( + + - {getContentText()} - + {chatDetails[0]?.meta?.group && ( + + {sender}{' '} + + )} + {chatDetail.message.type !== 'Text' ? {getContentImage(chatDetail)} : null} + + {getContentText(chatDetail)} + + - + ) )} )} diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index e5a1b5f9d6..928ebfce05 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -1,17 +1,16 @@ -import { useContext, useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; -import { CONSTANTS, NotificationEvent } from '@pushprotocol/restapi'; import { useSelector } from 'react-redux'; +import { CONSTANTS, NotificationEvent } from '@pushprotocol/restapi'; import { deviceSizes, notification } from 'blocks'; import { InAppChannelNotifications, InAppChatNotifications } from 'common'; import { useDeviceWidthCheck } from 'hooks'; -import { Context } from 'modules/chat/ChatModule'; export const useInAppNotifications = () => { const [isStreamConnected, setIsStreamConnected] = useState(false); - // const { setSelectedChatId } = useContext(Context); + const [newMessages, setNewMessages] = useState>>({}); const isMobile = useDeviceWidthCheck(parseInt(deviceSizes.mobileL)); const { userPushSDKInstance } = useSelector((state: any) => { return state.user; @@ -64,28 +63,49 @@ export const useInAppNotifications = () => { data ); - if (data.event === 'chat.message' || data.event === 'chat.request') { - if (data.origin === 'other') - notification.show({ - overlay: , + if ((data.event === 'chat.message' || data.event === 'chat.request') && data.origin === 'other') { + let updatedMessages: Record> = newMessages; + if (!updatedMessages[data.chatId]) { + updatedMessages[data.chatId] = []; + } + // Ensure the chat array length does not exceed 5 messages + if (updatedMessages[data.chatId].length > 5) { + updatedMessages[data.chatId] = updatedMessages[data.chatId].slice(-5); + } + updatedMessages[data.chatId].push(data); + setNewMessages(updatedMessages); + notification.show( + { + overlay: ( + { + resetChatMessages(data.chatId); + notification.hide(); + }} + /> + ), position: isMobile ? 'top-center' : 'bottom-right', duration: 5000, - // onClose: () => { - // notification.hide(); - // }, + onAutoClose: () => resetChatMessages(data.chatId), onClick: () => { + resetChatMessages(data.chatId); notification.hide(); }, - }); + }, + data.chatId + ); } - - //attached image text - - //group - //stacking }); }; + /* remove previous messages for a particular chat*/ + const resetChatMessages = (chatId: string) => { + const updatedMessages = newMessages; + delete updatedMessages[chatId]; + setNewMessages(updatedMessages); + }; + useEffect(() => { (async () => { if (userPushSDKInstance && userPushSDKInstance?.stream) { diff --git a/src/queries/hooks/chat/index.ts b/src/queries/hooks/chat/index.ts new file mode 100644 index 0000000000..11c0ddb952 --- /dev/null +++ b/src/queries/hooks/chat/index.ts @@ -0,0 +1 @@ +export * from './useGetGroupInfo'; diff --git a/src/queries/hooks/chat/useGetGroupInfo.ts b/src/queries/hooks/chat/useGetGroupInfo.ts new file mode 100644 index 0000000000..a5af574701 --- /dev/null +++ b/src/queries/hooks/chat/useGetGroupInfo.ts @@ -0,0 +1,26 @@ +import { useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { useSelector } from 'react-redux'; + +import { userProfileDetails } from '../../queryKeys'; +import { getGroupInfo } from '../../services'; + +import { UserStoreType } from 'types'; +import { GroupInfoResponse } from '../../types'; + +/** + * @param chainId + * @returns query response + */ +export const useGetGroupInfo = (chatId?: string, config?: Partial>) => { + const { userPushSDKInstance } = useSelector((state: UserStoreType) => { + return state.user; + }); + + const query = useQuery({ + queryKey: [userProfileDetails, userPushSDKInstance?.account, chatId || ''], + enabled: !!chatId, + queryFn: () => getGroupInfo(userPushSDKInstance, chatId || ''), + ...config, + }); + return query; +}; diff --git a/src/queries/hooks/index.ts b/src/queries/hooks/index.ts index af7cf2c265..5ceff9be7e 100644 --- a/src/queries/hooks/index.ts +++ b/src/queries/hooks/index.ts @@ -1,5 +1,6 @@ export * from './createChannel'; export * from './channels'; +export * from './chat'; export * from './user'; export * from './rewards'; export * from './pointsVault'; diff --git a/src/queries/hooks/user/useGetProfileDetails.ts b/src/queries/hooks/user/useGetProfileDetails.ts index a583bd85b5..7ee317795d 100644 --- a/src/queries/hooks/user/useGetProfileDetails.ts +++ b/src/queries/hooks/user/useGetProfileDetails.ts @@ -4,7 +4,6 @@ import { useSelector } from 'react-redux'; import { userProfileDetails } from '../../queryKeys'; import { getUserProfileDetails } from '../../services'; -//Types import { UserStoreType } from 'types'; import { UserProfileDetailsResponse } from '../../types'; diff --git a/src/queries/models/chat/getGroupInfoModelCreator.ts b/src/queries/models/chat/getGroupInfoModelCreator.ts new file mode 100644 index 0000000000..520141820c --- /dev/null +++ b/src/queries/models/chat/getGroupInfoModelCreator.ts @@ -0,0 +1,4 @@ +import { GroupInfoResponse } from '../../types'; + +//any remodelling needed in the response can be done here +export const getGroupInfoModelCreator = (response: GroupInfoResponse): GroupInfoResponse => response; diff --git a/src/queries/models/chat/index.ts b/src/queries/models/chat/index.ts new file mode 100644 index 0000000000..09b7b550d4 --- /dev/null +++ b/src/queries/models/chat/index.ts @@ -0,0 +1 @@ +export * from './getGroupInfoModelCreator'; diff --git a/src/queries/models/index.ts b/src/queries/models/index.ts index fdcb1f07a9..66edccfb44 100644 --- a/src/queries/models/index.ts +++ b/src/queries/models/index.ts @@ -2,3 +2,4 @@ export * from './channels'; export * from './user'; export * from './rewards'; export * from './pointsVault'; +export * from './chat'; diff --git a/src/queries/services/chat/getGroupInfo.ts b/src/queries/services/chat/getGroupInfo.ts new file mode 100644 index 0000000000..61b0724718 --- /dev/null +++ b/src/queries/services/chat/getGroupInfo.ts @@ -0,0 +1,5 @@ +import { PushAPI } from '@pushprotocol/restapi'; +import { getGroupInfoModelCreator } from '../../models'; + +export const getGroupInfo = (userPushSDKInstance: PushAPI, chatId: string) => + userPushSDKInstance.chat.group.info(chatId).then(getGroupInfoModelCreator); diff --git a/src/queries/services/chat/index.ts b/src/queries/services/chat/index.ts new file mode 100644 index 0000000000..df1c03bbc6 --- /dev/null +++ b/src/queries/services/chat/index.ts @@ -0,0 +1 @@ +export * from './getGroupInfo'; diff --git a/src/queries/services/index.ts b/src/queries/services/index.ts index 632b38dfaa..0697336462 100644 --- a/src/queries/services/index.ts +++ b/src/queries/services/index.ts @@ -5,3 +5,4 @@ export * from './pointsVault'; export * from './createChannel'; export * from './analytics'; export * from './notificationSettings'; +export * from './chat'; diff --git a/src/queries/types/chat.ts b/src/queries/types/chat.ts new file mode 100644 index 0000000000..1d742c1797 --- /dev/null +++ b/src/queries/types/chat.ts @@ -0,0 +1,3 @@ +import { GroupDTO, GroupInfoDTO } from '@pushprotocol/restapi'; + +export type GroupInfoResponse = GroupDTO | GroupInfoDTO; diff --git a/src/queries/types/index.ts b/src/queries/types/index.ts index a99590a6c3..05869cb58f 100644 --- a/src/queries/types/index.ts +++ b/src/queries/types/index.ts @@ -4,3 +4,4 @@ export * from './rewards'; export * from './pointsVault'; export * from './createChannel'; export * from './notificationsettings'; +export * from './chat'; From be40adaa1f5644845e53a5f3ad2128d0dbc35b87 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 29 Oct 2024 15:57:45 +0530 Subject: [PATCH 03/14] fixed minor issue --- src/blocks/notification/Notification.tsx | 30 ++++++++++------------ src/common/hooks/useInAppNotifications.tsx | 3 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/blocks/notification/Notification.tsx b/src/blocks/notification/Notification.tsx index cede0c0d6e..9a46902b4f 100644 --- a/src/blocks/notification/Notification.tsx +++ b/src/blocks/notification/Notification.tsx @@ -117,22 +117,20 @@ const toastIds: Array = []; // Export the notification object with show and hide methods const notification = { show: (config: NotificationProps, id?: string) => { - if (toastIds.find((toastId) => toastId === id)) { - toast.custom(() => , { - id: id, - duration: config.duration || Infinity, - position: config.position || 'bottom-right', - onAutoClose: config.onAutoClose, - }); - } else { - const toastId = toast.custom(() => , { - id: id, - duration: config.duration || Infinity, - position: config.position || 'bottom-right', - onAutoClose: config.onAutoClose, - }); - toastIds.push(toastId); - } + toast.custom(() => , { + id: id, + duration: config.duration || Infinity, + position: config.position || 'bottom-right', + onAutoClose: config.onAutoClose, + }); + + const toastId = toast.custom(() => , { + id: id, + duration: config.duration || Infinity, + position: config.position || 'bottom-right', + onAutoClose: config.onAutoClose, + }); + if (!toastIds.find((toastId) => toastId === id)) toastIds.push(toastId); }, hide: () => { if (toastIds.length > 0) { diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index 928ebfce05..48787d79d0 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -72,7 +72,8 @@ export const useInAppNotifications = () => { if (updatedMessages[data.chatId].length > 5) { updatedMessages[data.chatId] = updatedMessages[data.chatId].slice(-5); } - updatedMessages[data.chatId].push(data); + if (!(updatedMessages[data.chatId].length && data.event === 'chat.request')) + updatedMessages[data.chatId].push(data); setNewMessages(updatedMessages); notification.show( { From f86b165fe4dd031a00bc39ed44f665ed1141e72b Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 29 Oct 2024 16:11:07 +0530 Subject: [PATCH 04/14] fixed minor issue --- src/common/components/InAppChatNotifications.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index 0c8f9ce2cb..861af508e3 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -105,6 +105,8 @@ const InAppChatNotifications: FC = ({ chatDetails, /> ) : ( {displayName} From e7e6c15835d0817cefd21016da526ce170113e02 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Wed, 30 Oct 2024 12:06:06 +0530 Subject: [PATCH 05/14] fixed refetch --- src/common/components/InAppChatNotifications.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index 861af508e3..21fcb28594 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -23,8 +23,16 @@ type InAppChatNotificationsProps = { const InAppChatNotifications: FC = ({ chatDetails, onClose }) => { const { web3NameList }: AppContextType = useContext(AppContext)!; const fromAddress = caip10ToWallet(chatDetails[0]?.from); - const { data: userProfileDetails } = useGetUserProfileDetails(fromAddress); - const { data: groupInfo } = useGetGroupInfo(chatDetails[0]?.meta?.group ? chatDetails[0].chatId : ''); + 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(); From c40b671072f858f712bef779e07fdeadb131e7c1 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Fri, 1 Nov 2024 14:31:07 +0530 Subject: [PATCH 06/14] fixing stream --- src/common/components/InAppChatNotifications.tsx | 4 ++-- src/common/hooks/useInAppNotifications.tsx | 9 +++++++-- src/config/config-dev.js | 2 +- src/contexts/AppContext.tsx | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index 21fcb28594..8b05458227 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -49,10 +49,10 @@ const InAppChatNotifications: FC = ({ chatDetails, 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 === 'GIF') return 'GIF'; + if (chatDetail.message.type === 'MediaEmbed') return 'MediaEmbed'; }; const getContentImage = (chatDetail: any) => { - if (chatDetail.message.type === 'Image' || chatDetail.message.type === 'GIF') + if (chatDetail.message.type === 'Image' || chatDetail.message.type === 'MediaEmbed') return ( { useEffect(() => { (async () => { if (userPushSDKInstance && userPushSDKInstance?.stream) { + console.debug('attach stream'); await attachListeners(); } })(); // Cleanup listener on unmount - return () => {}; - }, [userPushSDKInstance?.account]); + return () => { + (async () => { + userPushSDKInstance?.stream.disconnect(); + })(); + }; + }, [userPushSDKInstance.uid]); return { isStreamConnected }; }; diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 185a95759c..633a42a378 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -113,7 +113,7 @@ export const addresses = { // For Sepolia pushToken: '0x37c779a1564DCc0e3914aB130e0e787d93e21804', // pushCoreV2: "0x8a965286c0752DFE821868312025091f60BD902A", // 15 min epoch - pushCoreV2: '0x5AB1520E2bd519BDab2e1347EEe81C00a77f4946', //21 days epoch + pushCoreV2: '0xadc928517f9bf7ee3ecd5bec390fc01036b1604e', //21 days epoch uniV2LPToken: '0x2333609Cc527a9309Cdad16E0742a3C6DC1C551b', uniswapV2Router02: '0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008', WETHAddress: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9', diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index 7ef381d0b3..ea49f22118 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -312,7 +312,8 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { CONSTANTS.STREAM.VIDEO, ]); - if (userInstance.readmode()) await stream.connect(); + // if (userInstance.readmode()) + await stream.connect(); console.debug('src::contexts::AppContext::setupStream::User Intance Stream Connected', userInstance); } }; From e00255959a8ba0c7e4e90a165df73c63f7d04330 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Mon, 4 Nov 2024 21:02:02 +0530 Subject: [PATCH 07/14] issue with duplicate stream event --- package.json | 2 +- src/blocks/notification/Notification.tsx | 12 +++--- src/common/hooks/useInAppNotifications.tsx | 43 ++++++++++++++-------- src/contexts/AppContext.tsx | 6 +-- yarn.lock | 10 ++--- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index f442a5b646..b67a87143f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@metamask/eth-sig-util": "^4.0.0", "@mui/icons-material": "^5.8.4", "@mui/material": "^5.5.0", - "@pushprotocol/restapi": "1.7.25", + "@pushprotocol/restapi": "1.7.28", "@pushprotocol/socket": "0.5.3", "@pushprotocol/uiweb": "1.7.0", "@radix-ui/react-dialog": "^1.1.1", diff --git a/src/blocks/notification/Notification.tsx b/src/blocks/notification/Notification.tsx index 9a46902b4f..62dc40fde5 100644 --- a/src/blocks/notification/Notification.tsx +++ b/src/blocks/notification/Notification.tsx @@ -117,12 +117,12 @@ const toastIds: Array = []; // Export the notification object with show and hide methods const notification = { show: (config: NotificationProps, id?: string) => { - toast.custom(() => , { - id: id, - duration: config.duration || Infinity, - position: config.position || 'bottom-right', - onAutoClose: config.onAutoClose, - }); + // toast.custom(() => , { + // id: id, + // duration: config.duration || Infinity, + // position: config.position || 'bottom-right', + // onAutoClose: config.onAutoClose, + // }); const toastId = toast.custom(() => , { id: id, diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index e7b752ac68..b7c02952e2 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -16,6 +16,7 @@ export const useInAppNotifications = () => { return state.user; }); const attachListeners = async () => { + console.debug('attach listners'); userPushSDKInstance?.stream?.on(CONSTANTS.STREAM.CONNECT, (err: Error) => { console.debug( 'src::common::hooks::useStream::attachListeners::CONNECT::', @@ -42,9 +43,12 @@ export const useInAppNotifications = () => { userPushSDKInstance?.uid, userPushSDKInstance?.stream?.uid, userPushSDKInstance?.stream, - data + data, + data.source, + typeof data.source, + data.source != 'PUSH_CHAT' ); - if (data.source !== 'PUSH_CHAT') + if (data.source != 'PUSH_CHAT') notification.show({ overlay: , position: isMobile ? 'top-center' : 'bottom-right', @@ -72,8 +76,11 @@ export const useInAppNotifications = () => { if (updatedMessages[data.chatId].length > 5) { updatedMessages[data.chatId] = updatedMessages[data.chatId].slice(-5); } - if (!(updatedMessages[data.chatId].length && data.event === 'chat.request')) - updatedMessages[data.chatId].push(data); + if (!(updatedMessages[data.chatId].length && data.event === 'chat.request')) { + if (!updatedMessages[data.chatId].some((msg) => msg?.reference === data?.reference)) { + updatedMessages[data.chatId].push(data); + } + } setNewMessages(updatedMessages); notification.show( { @@ -107,21 +114,25 @@ export const useInAppNotifications = () => { setNewMessages(updatedMessages); }; - useEffect(() => { - (async () => { - if (userPushSDKInstance && userPushSDKInstance?.stream) { - console.debug('attach stream'); - await attachListeners(); - } - })(); + const streamAttach = () => { + if (userPushSDKInstance && userPushSDKInstance?.stream && !userPushSDKInstance?.stream.disconnected) { + console.debug('attach stream first time', userPushSDKInstance); + attachListeners(); + } + }; + const streamCleanup = () => { + console.debug('disconnect stream first time', userPushSDKInstance); + if (userPushSDKInstance && userPushSDKInstance?.stream) { + userPushSDKInstance?.stream?.disconnect(); + } + }; - // Cleanup listener on unmount + useEffect(() => { + streamAttach(); return () => { - (async () => { - userPushSDKInstance?.stream.disconnect(); - })(); + streamCleanup(); }; - }, [userPushSDKInstance.uid]); + }, [userPushSDKInstance?.account, userPushSDKInstance?.readmode()]); return { isStreamConnected }; }; diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index ea49f22118..a397be3143 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -223,7 +223,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { // call initializePushSDK if decryptedPGPKeys is not null if (decryptedPGPKeys) { console.debug('src::contexts::AppContext::initializePushSdkReadMode::Called initializePushSDK()'); - return initializePushSDK(); + return initializePushSDK(wallet); } // else initialize push sdk in read mode @@ -307,7 +307,6 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { CONSTANTS.STREAM.CONNECT, CONSTANTS.STREAM.DISCONNECT, CONSTANTS.STREAM.CHAT, - CONSTANTS.STREAM.CHAT_OPS, CONSTANTS.STREAM.NOTIF, CONSTANTS.STREAM.VIDEO, ]); @@ -483,6 +482,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { const initialize = async () => { // const librarySigner = await provider?.getSigner(account); // If you need to use librarySigner in async operations // if (!account || !appConfig?.appEnv) return; + console.debug('initializePushSdkReadMode called', userPushSDKInstance?.account); if (wallet?.accounts?.length > 0) { await initializePushSdkReadMode(); } else { @@ -490,7 +490,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { } }; initialize(); - }, [account, provider]); + }, [account]); const createUserIfNecessary = async (): Promise => { try { diff --git a/yarn.lock b/yarn.lock index 4ef4507c8b..9e680c7ea7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4055,9 +4055,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/restapi@npm:1.7.25": - version: 1.7.25 - resolution: "@pushprotocol/restapi@npm:1.7.25" +"@pushprotocol/restapi@npm:1.7.28": + version: 1.7.28 + resolution: "@pushprotocol/restapi@npm:1.7.28" dependencies: "@metamask/eth-sig-util": "npm:^5.0.2" axios: "npm:^0.27.2" @@ -4080,7 +4080,7 @@ __metadata: peerDependenciesMeta: ethers: optional: true - checksum: 10/1da9268e81c3038871904336f16b6161fb039e9d0995a060f403f95c553a8ca8c9faada73c1806fb8ba3557cbdcc33b53c0e223c4cb743ddc9ed24da0b91c992 + checksum: 10/63fe891a9adb7a9bb911d059bbcb633d432eeed2c71ec1c1ab54a91895ca59f205fd46b450f9f50890d9b1e74120180b0ac45b869a3bdf0c7077445235c45d65 languageName: node linkType: hard @@ -18491,7 +18491,7 @@ __metadata: "@metamask/eth-sig-util": "npm:^4.0.0" "@mui/icons-material": "npm:^5.8.4" "@mui/material": "npm:^5.5.0" - "@pushprotocol/restapi": "npm:1.7.25" + "@pushprotocol/restapi": "npm:1.7.28" "@pushprotocol/socket": "npm:0.5.3" "@pushprotocol/uiweb": "npm:1.7.0" "@radix-ui/react-dialog": "npm:^1.1.1" From 18aa0b9c7fc8897f9a15ac4e3e3734baad92ea4c Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 5 Nov 2024 12:59:04 +0530 Subject: [PATCH 08/14] fixed multiple connections --- package.json | 2 +- src/common/hooks/useInAppNotifications.tsx | 6 ++---- src/contexts/AppContext.tsx | 3 +-- yarn.lock | 12 ++++++------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b67a87143f..8dfefed31b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@mui/material": "^5.5.0", "@pushprotocol/restapi": "1.7.28", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "1.7.0", + "@pushprotocol/uiweb": "/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-switch": "^1.1.0", diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index b7c02952e2..46bddfc9f2 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -16,7 +16,6 @@ export const useInAppNotifications = () => { return state.user; }); const attachListeners = async () => { - console.debug('attach listners'); userPushSDKInstance?.stream?.on(CONSTANTS.STREAM.CONNECT, (err: Error) => { console.debug( 'src::common::hooks::useStream::attachListeners::CONNECT::', @@ -62,6 +61,7 @@ export const useInAppNotifications = () => { console.debug( 'src::common::hooks::useStream::attachListeners::CHAT::', userPushSDKInstance?.uid, + userPushSDKInstance?.stream.connected(), userPushSDKInstance?.stream?.uid, userPushSDKInstance?.stream, data @@ -115,13 +115,11 @@ export const useInAppNotifications = () => { }; const streamAttach = () => { - if (userPushSDKInstance && userPushSDKInstance?.stream && !userPushSDKInstance?.stream.disconnected) { - console.debug('attach stream first time', userPushSDKInstance); + if (userPushSDKInstance && userPushSDKInstance?.stream) { attachListeners(); } }; const streamCleanup = () => { - console.debug('disconnect stream first time', userPushSDKInstance); if (userPushSDKInstance && userPushSDKInstance?.stream) { userPushSDKInstance?.stream?.disconnect(); } diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index a397be3143..af8e13f1bb 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -288,10 +288,10 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { progress: 100, }); } - dispatch(setUserPushSDKInstance(userInstance)); // connect stream as well await setupStream(userInstance); + dispatch(setUserPushSDKInstance(userInstance)); return userInstance; } catch (error) { // Handle initialization error @@ -311,7 +311,6 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { CONSTANTS.STREAM.VIDEO, ]); - // if (userInstance.readmode()) await stream.connect(); console.debug('src::contexts::AppContext::setupStream::User Intance Stream Connected', userInstance); } diff --git a/yarn.lock b/yarn.lock index 9e680c7ea7..efbb719b76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4096,9 +4096,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:1.7.0": - version: 1.7.0 - resolution: "@pushprotocol/uiweb@npm:1.7.0" +"@pushprotocol/uiweb@file:/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb::locator=pushdapp%40workspace%3A.": + version: 1.5.0-alpha.4 + resolution: "@pushprotocol/uiweb@file:/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb#/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb::hash=69a506&locator=pushdapp%40workspace%3A." dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" @@ -4132,7 +4132,7 @@ __metadata: react-twitter-embed: "npm:^4.0.4" uuid: "npm:^9.0.1" peerDependencies: - "@pushprotocol/restapi": 1.7.25 + "@pushprotocol/restapi": 1.7.28 "@pushprotocol/socket": ^0.5.0 axios: ^0.27.2 openpgp: ^5.8.0 @@ -4140,7 +4140,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/2b0d744503655f3758badc0ccce7f7cb7db3e0121541c450eb30ea2474a886a4217319642a830d4f7a64fca106b8222c3ff678da3e2c83ce7fc178583e76c618 + checksum: 10/0cab303adbdfacd363ba0b9bfc02a58fd235d64825372904d6ffb6d9b7beca9c6449804cbbcc505a7c731a21aaae3d4a2da9c5498cb85b38a07a6e8a0aeb6eb9 languageName: node linkType: hard @@ -18493,7 +18493,7 @@ __metadata: "@mui/material": "npm:^5.5.0" "@pushprotocol/restapi": "npm:1.7.28" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": "npm:1.7.0" + "@pushprotocol/uiweb": /Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0" From 7ba896d1932f60b174a7e75dc779cd478c840ab3 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Tue, 5 Nov 2024 13:02:31 +0530 Subject: [PATCH 09/14] fixed multiple connections --- src/blocks/notification/Notification.tsx | 7 ------- src/common/hooks/useInAppNotifications.tsx | 9 ++------- src/config/config-dev.js | 2 +- src/contexts/AppContext.tsx | 1 - 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/blocks/notification/Notification.tsx b/src/blocks/notification/Notification.tsx index 62dc40fde5..8fefbe50af 100644 --- a/src/blocks/notification/Notification.tsx +++ b/src/blocks/notification/Notification.tsx @@ -117,13 +117,6 @@ const toastIds: Array = []; // Export the notification object with show and hide methods const notification = { show: (config: NotificationProps, id?: string) => { - // toast.custom(() => , { - // id: id, - // duration: config.duration || Infinity, - // position: config.position || 'bottom-right', - // onAutoClose: config.onAutoClose, - // }); - const toastId = toast.custom(() => , { id: id, duration: config.duration || Infinity, diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index 46bddfc9f2..b09e8de057 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -41,11 +41,7 @@ export const useInAppNotifications = () => { userPushSDKInstance, userPushSDKInstance?.uid, userPushSDKInstance?.stream?.uid, - userPushSDKInstance?.stream, - data, - data.source, - typeof data.source, - data.source != 'PUSH_CHAT' + userPushSDKInstance?.stream ); if (data.source != 'PUSH_CHAT') notification.show({ @@ -63,8 +59,7 @@ export const useInAppNotifications = () => { userPushSDKInstance?.uid, userPushSDKInstance?.stream.connected(), userPushSDKInstance?.stream?.uid, - userPushSDKInstance?.stream, - data + userPushSDKInstance?.stream ); if ((data.event === 'chat.message' || data.event === 'chat.request') && data.origin === 'other') { diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 633a42a378..61bc7cb77b 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -113,7 +113,7 @@ export const addresses = { // For Sepolia pushToken: '0x37c779a1564DCc0e3914aB130e0e787d93e21804', // pushCoreV2: "0x8a965286c0752DFE821868312025091f60BD902A", // 15 min epoch - pushCoreV2: '0xadc928517f9bf7ee3ecd5bec390fc01036b1604e', //21 days epoch + pushCoreV2: '0x5F304C695B6035DfCC17bF571A9437Da9ebf7a86', //21 days epoch uniV2LPToken: '0x2333609Cc527a9309Cdad16E0742a3C6DC1C551b', uniswapV2Router02: '0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008', WETHAddress: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9', diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index af8e13f1bb..1ecc055873 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -481,7 +481,6 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { const initialize = async () => { // const librarySigner = await provider?.getSigner(account); // If you need to use librarySigner in async operations // if (!account || !appConfig?.appEnv) return; - console.debug('initializePushSdkReadMode called', userPushSDKInstance?.account); if (wallet?.accounts?.length > 0) { await initializePushSdkReadMode(); } else { From cab612bd1554550494641c5ee71a63dccac0e328 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:03:44 +0530 Subject: [PATCH 10/14] Update config-dev.js --- src/config/config-dev.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 61bc7cb77b..185a95759c 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -113,7 +113,7 @@ export const addresses = { // For Sepolia pushToken: '0x37c779a1564DCc0e3914aB130e0e787d93e21804', // pushCoreV2: "0x8a965286c0752DFE821868312025091f60BD902A", // 15 min epoch - pushCoreV2: '0x5F304C695B6035DfCC17bF571A9437Da9ebf7a86', //21 days epoch + pushCoreV2: '0x5AB1520E2bd519BDab2e1347EEe81C00a77f4946', //21 days epoch uniV2LPToken: '0x2333609Cc527a9309Cdad16E0742a3C6DC1C551b', uniswapV2Router02: '0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008', WETHAddress: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9', From 11a60d7a33fb25c0c9e1ed527b9b65ff264899b0 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Wed, 6 Nov 2024 17:27:50 +0530 Subject: [PATCH 11/14] updated sdk verion --- package.json | 4 ++-- src/common/hooks/useInAppNotifications.tsx | 4 +--- yarn.lock | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 8dfefed31b..1f2b0af930 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "@metamask/eth-sig-util": "^4.0.0", "@mui/icons-material": "^5.8.4", "@mui/material": "^5.5.0", - "@pushprotocol/restapi": "1.7.28", + "@pushprotocol/restapi": "1.7.29", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb", + "@pushprotocol/uiweb": "2.0.0-exp.10", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-switch": "^1.1.0", diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index b09e8de057..2f58a684ab 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -72,9 +72,7 @@ export const useInAppNotifications = () => { updatedMessages[data.chatId] = updatedMessages[data.chatId].slice(-5); } if (!(updatedMessages[data.chatId].length && data.event === 'chat.request')) { - if (!updatedMessages[data.chatId].some((msg) => msg?.reference === data?.reference)) { - updatedMessages[data.chatId].push(data); - } + updatedMessages[data.chatId].push(data); } setNewMessages(updatedMessages); notification.show( diff --git a/yarn.lock b/yarn.lock index efbb719b76..102fd21117 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4055,9 +4055,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/restapi@npm:1.7.28": - version: 1.7.28 - resolution: "@pushprotocol/restapi@npm:1.7.28" +"@pushprotocol/restapi@npm:1.7.29": + version: 1.7.29 + resolution: "@pushprotocol/restapi@npm:1.7.29" dependencies: "@metamask/eth-sig-util": "npm:^5.0.2" axios: "npm:^0.27.2" @@ -4080,7 +4080,7 @@ __metadata: peerDependenciesMeta: ethers: optional: true - checksum: 10/63fe891a9adb7a9bb911d059bbcb633d432eeed2c71ec1c1ab54a91895ca59f205fd46b450f9f50890d9b1e74120180b0ac45b869a3bdf0c7077445235c45d65 + checksum: 10/13afab4147598627c470f09706b859af116ffd4831bbb4de1e2f6b3490b5c10f5f06754b820a766614ac145912b9a455c974570a2763b82289aa57f37d55421a languageName: node linkType: hard @@ -4096,9 +4096,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@file:/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb::locator=pushdapp%40workspace%3A.": - version: 1.5.0-alpha.4 - resolution: "@pushprotocol/uiweb@file:/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb#/Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb::hash=69a506&locator=pushdapp%40workspace%3A." +"@pushprotocol/uiweb@npm:2.0.0-exp.10": + version: 2.0.0-exp.10 + resolution: "@pushprotocol/uiweb@npm:2.0.0-exp.10" dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" @@ -4132,7 +4132,7 @@ __metadata: react-twitter-embed: "npm:^4.0.4" uuid: "npm:^9.0.1" peerDependencies: - "@pushprotocol/restapi": 1.7.28 + "@pushprotocol/restapi": 1.7.29 "@pushprotocol/socket": ^0.5.0 axios: ^0.27.2 openpgp: ^5.8.0 @@ -4140,7 +4140,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/0cab303adbdfacd363ba0b9bfc02a58fd235d64825372904d6ffb6d9b7beca9c6449804cbbcc505a7c731a21aaae3d4a2da9c5498cb85b38a07a6e8a0aeb6eb9 + checksum: 10/b120174a55776b3c87948edd5a60ec82837e4454ef85b1a0b3b20dce41f27ae0c45a66a96744c72d9dc307c3306eaa538303a69227c474d3bd2dc1a065fb9040 languageName: node linkType: hard @@ -18491,9 +18491,9 @@ __metadata: "@metamask/eth-sig-util": "npm:^4.0.0" "@mui/icons-material": "npm:^5.8.4" "@mui/material": "npm:^5.5.0" - "@pushprotocol/restapi": "npm:1.7.28" + "@pushprotocol/restapi": "npm:1.7.29" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": /Users/monalishamishra/Desktop/epns/push-sdk/dist/packages/uiweb + "@pushprotocol/uiweb": "npm:2.0.0-exp.10" "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0" From 24a766187cf6b95be900db87923a689a9d089ad7 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Wed, 6 Nov 2024 18:00:08 +0530 Subject: [PATCH 12/14] fixed gif --- src/common/components/InAppChatNotifications.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index 8b05458227..aa1f11ac65 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -49,10 +49,14 @@ const InAppChatNotifications: FC = ({ chatDetails, 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') return 'MediaEmbed'; + if (chatDetail.message.type === 'MediaEmbed' || chatDetail.message.type === 'GIF') return 'GIF'; }; const getContentImage = (chatDetail: any) => { - if (chatDetail.message.type === 'Image' || chatDetail.message.type === 'MediaEmbed') + if ( + chatDetail.message.type === 'Image' || + chatDetail.message.type === 'MediaEmbed' || + chatDetail.message.type === 'GIF' + ) return ( Date: Thu, 7 Nov 2024 12:48:58 +0530 Subject: [PATCH 13/14] updated uiweb to 1.7.2 --- yarn.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 102fd21117..a59457cd38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4096,9 +4096,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:2.0.0-exp.10": - version: 2.0.0-exp.10 - resolution: "@pushprotocol/uiweb@npm:2.0.0-exp.10" +"@pushprotocol/uiweb@npm:1.7.2": + version: 1.7.2 + resolution: "@pushprotocol/uiweb@npm:1.7.2" dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" @@ -4140,7 +4140,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/b120174a55776b3c87948edd5a60ec82837e4454ef85b1a0b3b20dce41f27ae0c45a66a96744c72d9dc307c3306eaa538303a69227c474d3bd2dc1a065fb9040 + checksum: 10/8594689a4c814dae1cbc43500ae6e16e04a3cdadfc0b81130796ad06f64268e6b8ff986686323911266700972ec3a64870b335a97ed4e8766e826cbc504f13cf languageName: node linkType: hard @@ -18493,7 +18493,7 @@ __metadata: "@mui/material": "npm:^5.5.0" "@pushprotocol/restapi": "npm:1.7.29" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": "npm:2.0.0-exp.10" + "@pushprotocol/uiweb": "npm:1.7.2" "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0" From f256b8e6f332ce341c68d4eeeb51e0bac1bea0a7 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra Date: Thu, 7 Nov 2024 13:43:58 +0530 Subject: [PATCH 14/14] fixed review comments --- .../components/InAppChatNotifications.tsx | 54 +++++++++---------- src/queries/hooks/chat/useGetGroupInfo.ts | 6 +-- src/queries/hooks/user/index.ts | 2 +- ...Details.ts => useGetUserProfileDetails.ts} | 5 +- src/queries/queryKeys.ts | 1 + .../services/user/getUserProfileDetails.ts | 2 +- 6 files changed, 36 insertions(+), 34 deletions(-) rename src/queries/hooks/user/{useGetProfileDetails.ts => useGetUserProfileDetails.ts} (93%) diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx index aa1f11ac65..e4e33aa84d 100644 --- a/src/common/components/InAppChatNotifications.tsx +++ b/src/common/components/InAppChatNotifications.tsx @@ -20,6 +20,33 @@ type InAppChatNotificationsProps = { 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 ( + + ); + if (chatDetail.message.type === 'File') + return ( + + ); +}; + const InAppChatNotifications: FC = ({ chatDetails, onClose }) => { const { web3NameList }: AppContextType = useContext(AppContext)!; const fromAddress = caip10ToWallet(chatDetails[0]?.from); @@ -45,33 +72,6 @@ const InAppChatNotifications: FC = ({ chatDetails, const latestTimestamp = convertTimeStamp(chatDetails[chatDetails.length - 1]?.timestamp); - 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 ( - - ); - if (chatDetail.message.type === 'File') - return ( - - ); - }; - //optimise it and fix the close button z-index return ( ({ - queryKey: [userProfileDetails, userPushSDKInstance?.account, chatId || ''], + queryKey: [groupInfo, userPushSDKInstance?.account, chatId], enabled: !!chatId, - queryFn: () => getGroupInfo(userPushSDKInstance, chatId || ''), + queryFn: () => getGroupInfo(userPushSDKInstance, chatId!), ...config, }); return query; diff --git a/src/queries/hooks/user/index.ts b/src/queries/hooks/user/index.ts index 72fcb30fd9..9df9805f44 100644 --- a/src/queries/hooks/user/index.ts +++ b/src/queries/hooks/user/index.ts @@ -2,4 +2,4 @@ export * from './useGetUserSubscriptions'; export * from './useSubscribeChannel'; export * from './useUnsubscribeChannel'; export * from './useUpdateNotificationSettings'; -export * from './useGetProfileDetails'; +export * from './useGetUserProfileDetails'; diff --git a/src/queries/hooks/user/useGetProfileDetails.ts b/src/queries/hooks/user/useGetUserProfileDetails.ts similarity index 93% rename from src/queries/hooks/user/useGetProfileDetails.ts rename to src/queries/hooks/user/useGetUserProfileDetails.ts index 7ee317795d..f109872ef4 100644 --- a/src/queries/hooks/user/useGetProfileDetails.ts +++ b/src/queries/hooks/user/useGetUserProfileDetails.ts @@ -20,8 +20,9 @@ export const useGetUserProfileDetails = ( }); const query = useQuery({ - queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress || null], - queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress), + queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress], + enabled: !!userAddress, + queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress!), ...config, }); return query; diff --git a/src/queries/queryKeys.ts b/src/queries/queryKeys.ts index 7740110586..c9b8fab717 100644 --- a/src/queries/queryKeys.ts +++ b/src/queries/queryKeys.ts @@ -18,6 +18,7 @@ export const creatingNewChannel = 'creatingNewChannel'; export const deactivatingChannel = 'deactivatingChannel'; export const discordDetails = 'discordDetails'; export const generateUserIdByWallet = 'generateUserIdByWallet'; +export const groupInfo = 'groupInfo'; export const initiateNewChain = 'initiateNewChain'; export const pointsVaultApprovedUsers = 'pointsVaultApprovedUsers'; export const pointsVaultPendingUsers = 'pointsVaultPendingUsers'; diff --git a/src/queries/services/user/getUserProfileDetails.ts b/src/queries/services/user/getUserProfileDetails.ts index 77759ae14b..0cc61ff422 100644 --- a/src/queries/services/user/getUserProfileDetails.ts +++ b/src/queries/services/user/getUserProfileDetails.ts @@ -1,5 +1,5 @@ import { PushAPI } from '@pushprotocol/restapi'; import { getUserProfileDetailsModelCreator } from 'queries/models'; -export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address?: string) => +export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address: string) => userPushSDKInstance.profile.info({ overrideAccount: address }).then(getUserProfileDetailsModelCreator);