From 9c6383cd387479ed798d774f1c78a4b0792cd5d9 Mon Sep 17 00:00:00 2001 From: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:28:57 +0530 Subject: [PATCH] Alpha deployment (#1121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.61 * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.62 * ci(restapi): 🎉 cut release to restapi-v0.9.0 * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.63 * fix: fix errors * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.64 * fix: changed stream type to any * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.16 * fix: minor change * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.17 * fix: minor fix * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.36 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.37 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.38 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.39 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.39 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.40 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.41 * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.65 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.42 * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.66 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.43 * fix: fixed build issues * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.36 * ci(uiweb): 🎉 cut beta release to uiweb-v0.0.1-alpha.44 * ci(restapi): 🎉 cut beta release to restapi-v0.0.1-alpha.67 * fix: fixed minor bugs * fix: fixed chatpreview and widget issues * fix: fixed chat bugs * fix: fixed readmode --------- Co-authored-by: Mohammed S --- .../src/app/ChatUITest/ChatPreviewList.tsx | 2 +- .../src/app/ChatUITest/ChatViewComponent.tsx | 2 +- packages/restapi/src/lib/pushapi/chat.ts | 6 +-- packages/restapi/src/lib/pushapi/space.ts | 2 +- .../chat/ChatPreviewList/ChatPreviewList.tsx | 44 ++++++++++--------- .../src/lib/components/chat/helpers/helper.ts | 3 +- .../components/chat/reusables/AddWallets.tsx | 3 +- .../lib/dataProviders/ChatDataProvider.tsx | 17 ++++--- packages/uiweb/src/lib/helpers/chat/search.ts | 13 +++--- .../uiweb/src/lib/hooks/useGetChatProfile.ts | 11 +++-- 10 files changed, 57 insertions(+), 46 deletions(-) diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx index c83ed8dae..fe1f00287 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx @@ -46,7 +46,7 @@ const ChatPreviewListTest = () => { onPaging={(chats) => { console.log("paging chats are: ", chats) }} onPreload={(chats) => { console.log("preload chats are: ", chats) }} // listType='SEARCH' - // searchParamter='0x784546737C60d54946B3De932f2246187c7E1dD9' + // searchParamter='0x56A734ba4C7c7b117774C9aAcCEf521eBE66d65b' /> diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx index 7f628fcd4..72f09c750 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx @@ -20,7 +20,7 @@ const ChatViewComponentTest = () => { console.log("Verification Failed")} - chatId='0xc64444D6a076D6a8252390709A1270bfBBa32e2d' + chatId='0x56A734ba4C7c7b117774C9aAcCEf521eBE66d65b' chatProfileLeftHelperComponent={console.debug('clicked')}/>} chatProfileRightHelperComponent={
right component
} diff --git a/packages/restapi/src/lib/pushapi/chat.ts b/packages/restapi/src/lib/pushapi/chat.ts index 556c308e2..aef943ca9 100644 --- a/packages/restapi/src/lib/pushapi/chat.ts +++ b/packages/restapi/src/lib/pushapi/chat.ts @@ -73,7 +73,7 @@ export class Chat { page: options?.page, limit: options?.limit, env: this.env, - toDecrypt: !!this.signer, // Set to false if signer is undefined or null, + toDecrypt: !!this.decryptedPgpPvtKey, // Set to false if signer is undefined or null, }; switch (type) { @@ -96,7 +96,7 @@ export class Chat { const latestMessages = await PUSH_CHAT.latest({ threadhash: threadHash, - toDecrypt: !!this.signer, // Set to false if signer is undefined or null, + toDecrypt: !!this.decryptedPgpPvtKey, // Set to false if signer is undefined or null, pgpPrivateKey: this.decryptedPgpPvtKey, account: this.account, env: this.env, @@ -131,7 +131,7 @@ export class Chat { env: this.env, threadhash: reference, pgpPrivateKey: this.decryptedPgpPvtKey, - toDecrypt: !!this.signer, // Set to false if signer is undefined or null, + toDecrypt: !!this.decryptedPgpPvtKey, // Set to false if signer is undefined or null, limit: options?.limit, }); const listType = intent ? 'CHATS' : 'REQUESTS'; diff --git a/packages/restapi/src/lib/pushapi/space.ts b/packages/restapi/src/lib/pushapi/space.ts index dff3dbded..c92225a58 100644 --- a/packages/restapi/src/lib/pushapi/space.ts +++ b/packages/restapi/src/lib/pushapi/space.ts @@ -485,7 +485,7 @@ export class Space { page: options?.page, limit: options?.limit, env: this.env, - toDecrypt: !!this.signer, // Set to false if signer is undefined or null, + toDecrypt: !!this.decryptedPgpPvtKey, // Set to false if signer is undefined or null, }; switch (type) { diff --git a/packages/uiweb/src/lib/components/chat/ChatPreviewList/ChatPreviewList.tsx b/packages/uiweb/src/lib/components/chat/ChatPreviewList/ChatPreviewList.tsx index e185f1466..b8e5b5eb1 100644 --- a/packages/uiweb/src/lib/components/chat/ChatPreviewList/ChatPreviewList.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatPreviewList/ChatPreviewList.tsx @@ -19,8 +19,9 @@ import useGetGroupByIDnew from '../../../hooks/chat/useGetGroupByIDnew'; import { Button, Section, Span, Spinner } from '../../reusables'; import { ChatPreview } from '../ChatPreview'; -import { getAddress, pCAIP10ToWallet } from '../../../helpers'; +import { getAddress, getNewChatUser, pCAIP10ToWallet, walletToPCAIP10 } from '../../../helpers'; import { + displayDefaultUser, generateRandomNonce, transformChatItems, transformStreamToIChatPreviewPayload, @@ -408,21 +409,21 @@ export const ChatPreviewList: React.FC = ( // Effects // If account, env or signer changes - // useEffect(() => { - // setChatPreviewList({ - // nonce: generateRandomNonce(), - // items: [], - // page: 1, - // preloading: true, - // loading: false, - // loaded: false, - // reset: false, - // resume: false, - // errored: false, - // error: null, - // }); - // resetBadge(); - // }, [account, env]); + useEffect(() => { + setChatPreviewList({ + nonce: generateRandomNonce(), + items: [], + page: 1, + preloading: true, + loading: false, + loaded: false, + reset: false, + resume: false, + errored: false, + error: null, + }); + resetBadge(); + }, [account, env,signer]); useEffect(() => { if (options?.onLoading) { @@ -506,7 +507,7 @@ export const ChatPreviewList: React.FC = ( } - }, [chatPreviewList.reset]); + }, [chatPreviewList.reset,user?.readmode()]); // If loading becomes active useEffect(() => { @@ -579,7 +580,7 @@ export const ChatPreviewList: React.FC = ( try { if (options?.searchParamter) { let formattedChatId: string | null = options?.searchParamter; - let userProfile: IUser | null = null; + let userProfile: IUser | undefined = undefined; let groupProfile: Group; //check if ens then convert to address @@ -596,9 +597,12 @@ export const ChatPreviewList: React.FC = ( if (!error) { if (await ethers.utils.isAddress(formattedChatId)) { //fetch profile - userProfile = await fetchUserProfile({ - profileId: formattedChatId, + userProfile = await getNewChatUser({ + searchText: formattedChatId, + env, + fetchChatProfile:fetchUserProfile, user + }); } else { //fetch group info diff --git a/packages/uiweb/src/lib/components/chat/helpers/helper.ts b/packages/uiweb/src/lib/components/chat/helpers/helper.ts index 2c3832fd1..600e96554 100644 --- a/packages/uiweb/src/lib/components/chat/helpers/helper.ts +++ b/packages/uiweb/src/lib/components/chat/helpers/helper.ts @@ -4,6 +4,7 @@ import { IFeeds, IUser, ParticipantStatus } from '@pushprotocol/restapi'; import { getAddress, walletToPCAIP10 } from '../../../helpers'; import { Env, } from '@pushprotocol/restapi'; import moment from 'moment'; +import { ProfilePicture } from '../../../config'; export const profilePicture = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAvklEQVR4AcXBsW2FMBiF0Y8r3GQb6jeBxRauYRpo4yGQkMd4A7kg7Z/GUfSKe8703fKDkTATZsJsrr0RlZSJ9r4RLayMvLmJjnQS1d6IhJkwE2bT13U/DBzp5BN73xgRZsJMmM1HOolqb/yWiWpvjJSUiRZWopIykTATZsJs5g+1N6KSMiO1N/5DmAkzYTa9Lh6MhJkwE2ZzSZlo7xvRwson3txERzqJhJkwE2bT6+JhoKTMJ2pvjAgzYSbMfgDlXixqjH6gRgAAAABJRU5ErkJggg==`; @@ -12,7 +13,7 @@ export const displayDefaultUser = ({ caip10 }: { caip10: string }): IUser => { did: caip10, wallets: caip10, publicKey: 'temp', - profilePicture: profilePicture, + profilePicture: ProfilePicture, encryptedPrivateKey: 'temp', encryptionType: 'temp', signature: 'temp', diff --git a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx index f78333f3c..092155fa8 100644 --- a/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx +++ b/packages/uiweb/src/lib/components/chat/reusables/AddWallets.tsx @@ -54,7 +54,7 @@ export const AddWallets = ({ const theme = useContext(ThemeContext); const [filteredUserData, setFilteredUserData] = useState(null); - const { env } = useChatData(); + const { env,user } = useChatData(); const isMobile = useMediaQuery(device.mobileL); const { fetchUserProfile } = useUserProfile(); const groupInfoToast = useToast(); @@ -76,6 +76,7 @@ export const AddWallets = ({ searchText: searchedText, fetchChatProfile:fetchUserProfile, env, + user }); if (newChatUser) { setFilteredUserData(newChatUser); diff --git a/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx b/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx index 48b644fb3..e132025d8 100644 --- a/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx +++ b/packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx @@ -64,18 +64,21 @@ export const ChatUIProvider = ({ useEffect(() => { (async () => { resetStates(); - setEnvVal(env); - + + let address; if (Object.keys(signer || {}).length && !user) { - const address = await getAddressFromSigner(signer!); - setAccountVal(address); + address = await getAddressFromSigner(signer!); + // setAccountVal(address); } else if (!signer && user) { const profile = await fetchUserProfile({user}); - setAccountVal(pCAIP10ToWallet(profile?.wallets)); + address = (pCAIP10ToWallet(profile?.wallets)); } else { - setAccountVal(GUEST_MODE_ACCOUNT); + address = GUEST_MODE_ACCOUNT; } + setEnvVal(env); + setAccountVal(address); setSignerVal(signer); + setUserVal(user); setPgpPrivateKeyVal(pgpPrivateKey); })(); @@ -84,7 +87,7 @@ export const ChatUIProvider = ({ useEffect(() => { (async () => { - if ((accountVal && envVal && signerVal) ||(accountVal == GUEST_MODE_ACCOUNT && envVal && !userVal) ) { + if ((accountVal && envVal ) ) { const pushUser = await initializeUser({ signer: signerVal, account: accountVal!, diff --git a/packages/uiweb/src/lib/helpers/chat/search.ts b/packages/uiweb/src/lib/helpers/chat/search.ts index 19684bbbd..2c228c3b9 100644 --- a/packages/uiweb/src/lib/helpers/chat/search.ts +++ b/packages/uiweb/src/lib/helpers/chat/search.ts @@ -1,4 +1,4 @@ -import type { Env, IFeeds, IUser } from '@pushprotocol/restapi'; +import type { Env, IFeeds, IUser, PushAPI } from '@pushprotocol/restapi'; import { add } from 'date-fns'; import { ethers } from 'ethers'; import { @@ -7,7 +7,7 @@ import { InfuraAPIKey, ProfilePicture, } from '../../config'; -import type { GetProfileParams } from '../../hooks'; +import type { FetchProfileParams, GetProfileParams } from '../../hooks'; import type { ChatFeedsType, NotificationFeedsType, @@ -54,17 +54,16 @@ export const getObjectsWithMatchingKeys = ( type getNewChatUserParamType = { searchText: string; - fetchChatProfile: ({ - profileId, - env - }: GetProfileParams) => Promise; + fetchChatProfile: any; env: Env; + user?: PushAPI }; export const getNewChatUser = async ({ searchText, fetchChatProfile, env, + user }: getNewChatUserParamType): Promise => { let chatProfile: IUser | undefined; let address: string | null = null; @@ -75,7 +74,7 @@ export const getNewChatUser = async ({ // address = await getAddress(searchText, env); // } if (address) { - chatProfile = await fetchChatProfile({ profileId: address, env }); + chatProfile = await fetchChatProfile({ profileId: address, env,user }); if (!chatProfile) chatProfile = displayDefaultUser({ caip10: walletToPCAIP10(address) }); return chatProfile; diff --git a/packages/uiweb/src/lib/hooks/useGetChatProfile.ts b/packages/uiweb/src/lib/hooks/useGetChatProfile.ts index 8937a7026..1a5b6bf72 100644 --- a/packages/uiweb/src/lib/hooks/useGetChatProfile.ts +++ b/packages/uiweb/src/lib/hooks/useGetChatProfile.ts @@ -1,22 +1,25 @@ import * as PushAPI from '@pushprotocol/restapi'; import { useCallback, useContext } from 'react'; import { ChatAndNotificationPropsContext } from '../context'; +import { GUEST_MODE_ACCOUNT } from '../config'; export interface GetProfileParams { - profileId: string; + profileId?: string | undefined; env:PushAPI.Env + user?:PushAPI.PushAPI | undefined } const useGetChatProfile = () => { const fetchChatProfile = useCallback( async ({ - profileId, - env + profileId = GUEST_MODE_ACCOUNT, + env, + user }: GetProfileParams): Promise => { try { const profile = await PushAPI.user.get({ env: env, - account: profileId, + account: profileId!, }); return profile; } catch (error) {