Skip to content

Commit

Permalink
fix: socket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pritipsingh committed Nov 15, 2023
1 parent e33870f commit 697ab6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ChatSupportTest = () => {
<SupportChat

signer={librarySigner}
supportAddress="0x6269C363695c5E14447a1b3873d7Ae4Ddf6E6eF7"
supportAddress="0x80f93506dd28cBcb235EF1D84BBCFF91F5B02D06"
apiKey="tAWEnggQ9Z.UaDBNjrvlJZx3giBTIQDcT8bKQo1O1518uF1Tea7rPwfzXv2ouV5rX9ViwgJUrXm"
env={env}
greetingMsg="How can i help you?"
Expand Down
21 changes: 16 additions & 5 deletions packages/uiweb/src/lib/components/supportChat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Constants, lightTheme } from '../../config';
import { useSDKSocket } from '../../hooks/useSDKSocket';
import { Div } from '../reusables/sharedStyling';
import { getAddressFromSigner } from '../../helpers';
import { sign } from 'crypto';
export type ChatProps = {
account?: string;
signer: SignerType;
Expand Down Expand Up @@ -88,26 +89,36 @@ export type ButtonStyleProps = {
env,
};



useEffect(() => {
(async () => {
if(signer) {
if (!account) {
const address = await getAddressFromSigner(signer);
setAccountadd(address);
const userAlice = await PushAPI.initialize(signer, {env: env , account:address});
setUserAlice(userAlice)

}
else{
setAccountadd(account);
const userAlice = await PushAPI.initialize(signer, {env: env , account:account});
setUserAlice(userAlice)

}

}
})();
},[signer])


useEffect(() => {
(
async() =>{
if(Object.keys(signer || {}).length && accountadd){
const userAlice = await PushAPI.initialize(signer!, {env: env , account:accountadd!});
setUserAlice(userAlice)
}
}
)()

},[signer, accountadd])

useEffect(() => {
setChats([]);
Expand Down

0 comments on commit 697ab6a

Please sign in to comment.