From 573a85893b9954f4d98d8b5bb75dd4d446dd0906 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com> Date: Thu, 7 Nov 2024 12:26:54 +0530 Subject: [PATCH] Stream and UserProfile Fix (#1419) * fix: fixed stream issue * fix: added new restapi version --- packages/uiweb/package.json | 2 +- .../src/lib/components/chat/UserProfile/UserProfile.tsx | 4 ++-- .../uiweb/src/lib/dataProviders/ChatDataProvider.tsx | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/uiweb/package.json b/packages/uiweb/package.json index a87ba1a70..2e4e416f1 100644 --- a/packages/uiweb/package.json +++ b/packages/uiweb/package.json @@ -38,7 +38,7 @@ "uuid": "^9.0.1" }, "peerDependencies": { - "@pushprotocol/restapi": "1.7.25", + "@pushprotocol/restapi": "1.7.29", "@pushprotocol/socket": "^0.5.0", "react": ">=16.8.0", "styled-components": "^6.0.8" diff --git a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx index 8fcea502f..c16649364 100644 --- a/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/UserProfile/UserProfile.tsx @@ -15,7 +15,7 @@ import { ProfileContainer } from '../reusables'; import { ThemeContext } from '../theme/ThemeProvider'; import { UpdateUserProfileModal } from './UpdateUserProfileModal'; -import { device } from '../../../config'; +import { GUEST_MODE_ACCOUNT, device } from '../../../config'; import VerticalEllipsisIcon from '../../../icons/VerticalEllipsis.svg'; import UserProfileIcon from '../../../icons/userCircleGear.svg'; import { MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE } from '../../../types'; @@ -96,7 +96,7 @@ export const UserProfile: React.FC = ({ member={{ web3Name: web3Name, abbrRecipient: shortenText(pCAIP10ToWallet(user?.account || ''), 8, true) as string, - recipient: user!.account, + recipient: user?.account || GUEST_MODE_ACCOUNT, icon: userProfile?.profile?.picture || null, }} copy={true} diff --git a/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx b/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx index 1ec828a7a..fe2b754c6 100644 --- a/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx +++ b/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx @@ -319,9 +319,10 @@ export const ChatUIProvider = ({ // check and filter out the streams which are not connected const streamsToConnect = streams.filter((stream) => !connectedStreams.listen?.includes(stream)); - + const uniqueStreams = [...new Set([...connectedStreams.listen, ...streams])]; + if (streamsToConnect.length) { - await userInstance.stream?.reinit(streams, { + await userInstance.stream?.reinit(uniqueStreams, { connection: { retries: 3, // number of retries in case of error }, @@ -415,10 +416,10 @@ export const ChatUIProvider = ({ // setTimeout(async () => { // console.debug('UIWeb::ChatDataProvider::attachListenersAndConnect::Timeout Connect', userInstance?.stream?.uid); - if (!userInstance.stream?.connected()) { + if (!userInstance?.stream?.connected()) { console.debug('UIWeb::ChatDataProvider::attachListenersAndConnect::Stream not connected', userInstance); - await userInstance.stream?.connect(); + await userInstance?.stream?.connect(); console.debug( 'UIWeb::ChatDataProvider::attachListenersAndConnect::Stream listeners attached and stream connected', userInstance?.stream?.uid