Skip to content

Commit

Permalink
Merge pull request #1276 from ethereum-push-notification-service/uiwe…
Browse files Browse the repository at this point in the history
…b-creategroup

added creategroup component from ui-web
  • Loading branch information
0xNilesh authored Oct 13, 2023
2 parents a219a4a + 28d9972 commit e53dba6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"@mui/lab": "^5.0.0-alpha.72",
"@mui/material": "^5.5.0",
"@pushprotocol/ledgerlive": "latest",
"@pushprotocol/restapi": "0.0.1-alpha.48",
"@pushprotocol/restapi": "0.0.1-alpha.49",
"@pushprotocol/socket": "latest",
"@pushprotocol/uiweb": "0.0.1-alpha.17",
"@pushprotocol/uiweb": "0.0.1-alpha.18",
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^4.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { fetchInbox } from 'helpers/w2w/user';
import { profilePicture } from 'config/W2WConfig';
import { useAccount, useDeviceWidthCheck } from 'hooks';
import { device } from 'config/Globals';
import { CreateGroupModal } from "@pushprotocol/uiweb";
import { ChatUIProvider } from '@pushprotocol/uiweb';


export const CreateGroupModalContent = ({ onClose, onConfirm: createGroup, toastObject }: ModalInnerComponentType) => {
const [createGroupState, setCreateGroupState] = React.useState<number>(1);
Expand All @@ -40,6 +43,7 @@ export const CreateGroupModalContent = ({ onClose, onConfirm: createGroup, toast
const createGroupToast = useToast();
const isMobile = useDeviceWidthCheck(600);


const handlePrevious = () => {
setCreateGroupState(1);
};
Expand Down Expand Up @@ -133,34 +137,8 @@ export const CreateGroupModalContent = ({ onClose, onConfirm: createGroup, toast
};
return (
<ThemeProvider theme={themes}>
<ModalContainer createGroupState={createGroupState}>

{createGroupState == 1 && (
<GroupDetailsContent
groupNameData={groupNameData}
groupDescriptionData={groupDescriptionData}
groupImageData={groupImageData}
groupTypeObject={groupTypeObject}
handleGroupNameData={setGroupNameData}
handleGroupDescriptionData={setGroupDescriptionData}
handleGroupImageData={setGroupImageData}
handleGroupTypeObject={setGroupTypeObject}
handleCreateGroupState={setCreateGroupState}
handlePrevious={handlePrevious}
handleClose={handleClose}
/>
)}
{createGroupState == 2 && (
<AddWalletContent
onSubmit={handleCreateGroup}
memberList={memberList}
handleMemberList={setMemberList}
isLoading={isLoading}
handlePrevious={handlePrevious}
handleClose={handleClose}
title={"Create Group"}
/>
)}
<ModalContainer>
<CreateGroupModal onClose={() => handleClose()} />
</ModalContainer>
</ThemeProvider>
);
Expand Down
19 changes: 15 additions & 4 deletions src/modules/chat/ChatModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { VideoCallContext } from 'contexts/VideoCallContext';
import { caip10ToWallet } from 'helpers/w2w';
import * as w2wHelper from 'helpers/w2w/';
import { checkIfGroup, rearrangeMembers } from 'helpers/w2w/groupChat';
import { useAccount, useDeviceWidthCheck, useSDKSocket } from 'hooks';
import { useAccount,useDeviceWidthCheck, useSDKSocket } from 'hooks';
import useModalBlur, { MODAL_POSITION } from 'hooks/useModalBlur';
import useToast from 'hooks/useToast';
import ChatBoxSection from 'sections/chat/ChatBoxSection';
Expand All @@ -43,6 +43,7 @@ import { checkIfIntent, getUpdatedChatAndIntent, getUpdatedGroupInfo } from 'hel
import { appConfig } from 'config';
import GLOBALS, { device, globalsMargin } from 'config/Globals';
import { fetchIntent } from 'helpers/w2w/user';
import { ChatUIProvider } from '@pushprotocol/uiweb';

export const ToastPosition: ToastOptions = {
position: 'top-right',
Expand All @@ -58,8 +59,8 @@ export const Context = React.createContext<AppContext | null>(null);

// Create Header
function Chat({ chatid }) {
const { account, chainId } = useAccount();
const { getUser, connectedUser, setConnectedUser, blockedLoading, setBlockedLoading, displayQR, setDisplayQR } =
const { account, chainId, provider } = useAccount();
const { getUser, pgpPvtKey,connectedUser, setConnectedUser, blockedLoading, setBlockedLoading, displayQR, setDisplayQR } =
useContext(ChatUserContext);
const { videoCallData } = useContext(VideoCallContext);

Expand All @@ -77,6 +78,7 @@ function Chat({ chatid }) {
const [activeTab, setCurrentTab] = useState<number>(0);
const [userShouldBeSearched, setUserShouldBeSearched] = useState<boolean>(false);
const [filteredUserData, setFilteredUserData] = useState<User[]>([]);
const [signerData, setSignerData] = useState();

const isMobile = useDeviceWidthCheck(600);
const queryClient = new QueryClient({});
Expand Down Expand Up @@ -274,11 +276,14 @@ const getUpdatedGroup = async(groupInfo) => {
showModal: showCreateGroupModal,
ModalComponent: CreateGroupModalComponent,
} = useModalBlur();
// const { pgpPvtKey } = useContext<any>(ChatUserContext);


const connectUser = async (): Promise<void> => {
const caip10:string = w2wHelper.walletToCAIP10({account});

const signer = await provider.getSigner();
setSignerData(signer);
console.log(signer, 'kkkk')

if(connectedUser?.wallets?.toLowerCase() !== caip10?.toLowerCase()){
await getUser();
Expand Down Expand Up @@ -392,8 +397,13 @@ const getUpdatedGroup = async(groupInfo) => {
}
};

useEffect(() => {
console.log(account, connectedUser?.privateKey, "kkkk")
}, [account, connectedUser?.privateKey])

return (
<Container>
<ChatUIProvider signer={signerData} env='prod' account={account} pgpPrivateKey={pgpPvtKey}>
<ItemHV2 ref={containerRef}>
{!isLoading ? (
<QueryClientProvider client={queryClient}>
Expand Down Expand Up @@ -513,6 +523,7 @@ const getUpdatedGroup = async(groupInfo) => {
/>
)}
</ItemHV2>
</ChatUIProvider>
</Container>
);
}
Expand Down

0 comments on commit e53dba6

Please sign in to comment.