Skip to content

Commit

Permalink
Alpha deployment (#1121)
Browse files Browse the repository at this point in the history
* 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 <shoaibmohammed92@gmail.com>
  • Loading branch information
mishramonalisha76 and mohammeds1992 authored Feb 21, 2024
1 parent b7305b3 commit 9c6383c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ChatViewComponentTest = () => {
<ChatView
onVerificationFail={() => console.log("Verification Failed")}

chatId='0xc64444D6a076D6a8252390709A1270bfBBa32e2d'
chatId='0x56A734ba4C7c7b117774C9aAcCEf521eBE66d65b'
chatProfileLeftHelperComponent={<img src={Img} onClick={()=>console.debug('clicked')}/>}
chatProfileRightHelperComponent={<div>right component</div>}

Expand Down
6 changes: 3 additions & 3 deletions packages/restapi/src/lib/pushapi/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/restapi/src/lib/pushapi/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -408,21 +409,21 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (
// 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) {
Expand Down Expand Up @@ -506,7 +507,7 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (
}


}, [chatPreviewList.reset]);
}, [chatPreviewList.reset,user?.readmode()]);

// If loading becomes active
useEffect(() => {
Expand Down Expand Up @@ -579,7 +580,7 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (
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
Expand All @@ -596,9 +597,12 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (
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
Expand Down
3 changes: 2 additions & 1 deletion packages/uiweb/src/lib/components/chat/helpers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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==`;

Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const AddWallets = ({
const theme = useContext(ThemeContext);

const [filteredUserData, setFilteredUserData] = useState<any>(null);
const { env } = useChatData();
const { env,user } = useChatData();
const isMobile = useMediaQuery(device.mobileL);
const { fetchUserProfile } = useUserProfile();
const groupInfoToast = useToast();
Expand All @@ -76,6 +76,7 @@ export const AddWallets = ({
searchText: searchedText,
fetchChatProfile:fetchUserProfile,
env,
user
});
if (newChatUser) {
setFilteredUserData(newChatUser);
Expand Down
17 changes: 10 additions & 7 deletions packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})();
Expand All @@ -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!,
Expand Down
13 changes: 6 additions & 7 deletions packages/uiweb/src/lib/helpers/chat/search.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -7,7 +7,7 @@ import {
InfuraAPIKey,
ProfilePicture,
} from '../../config';
import type { GetProfileParams } from '../../hooks';
import type { FetchProfileParams, GetProfileParams } from '../../hooks';
import type {
ChatFeedsType,
NotificationFeedsType,
Expand Down Expand Up @@ -54,17 +54,16 @@ export const getObjectsWithMatchingKeys = (

type getNewChatUserParamType = {
searchText: string;
fetchChatProfile: ({
profileId,
env
}: GetProfileParams) => Promise<IUser | undefined>;
fetchChatProfile: any;
env: Env;
user?: PushAPI
};

export const getNewChatUser = async ({
searchText,
fetchChatProfile,
env,
user
}: getNewChatUserParamType): Promise<IUser | undefined> => {
let chatProfile: IUser | undefined;
let address: string | null = null;
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions packages/uiweb/src/lib/hooks/useGetChatProfile.ts
Original file line number Diff line number Diff line change
@@ -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<PushAPI.IUser | undefined> => {
try {
const profile = await PushAPI.user.get({
env: env,
account: profileId,
account: profileId!,
});
return profile;
} catch (error) {
Expand Down

0 comments on commit 9c6383c

Please sign in to comment.