Skip to content

Commit

Permalink
fix: workaround for socket response
Browse files Browse the repository at this point in the history
  • Loading branch information
mishramonalisha76 committed Dec 2, 2023
1 parent f50ea38 commit 5dbc943
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ChatProfileTest = () => {
<div>
<ChatProfile
// chatId='0x455E5AA18469bC6ccEF49594645666C587A3a71B'
chatId='a72832107b8ae7624c1ec997cee8e8b2bc21db708465555c20c4d5e029210cd6'
chatId='81a077fbec5d64802a0feaeb26647250eb9a20894124c7bc1b2e044f360bf59f'
// chatId='36baf37e441fdd94e23406c6c716fc4e91a93a9ee68e070cd5b054534dbe09a6'
style="Info"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const ChatViewComponentTest = () => {
<h2>Chat UI Test page</h2>
{/* <CreateGroupModal onClose={()=>{console.log('in close')}} /> */}
<ChatViewComponentCard>
<CreateGroupModal onClose={()=>{console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/>
{/* <CreateGroupModal onClose={()=>{console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/> */}

<ChatView
onVerificationFail={() => console.log("BOIIII RETURNNNSSSSS")}
chatId='92ed5f3f3bcdf58976ce11395786398f6f9e3048d76dc7e6f53ea5d77092fdd6'
chatId='0x2B335905ab1C7574E7f15aF4C22cCBde000c47e0'

limit={10}
isConnected={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ChatViewListTest = () => {
{/* <Loader show={isLoading} /> */}

<ChatViewListCard>
<ChatViewList chatId='b8e068e02fe12d7136bc2f24408835573f30c6fbf0b65ea26ab4c7055a2c85f1' limit={10} />
<ChatViewList chatId='0x5fca4523728576d6DD418137D5C8F38de5e6A1A8' limit={10} />

</ChatViewListCard>
{/* <MessageInput chatId='196f58cbe07c7eb5716d939e0a3be1f15b22b2334d5179c601566600016860ac' isConnected={true} /> */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const ApproveRequestBubble = ({
borderRadius=" 0px 12px 12px 12px"
alignSelf="start"
justifyContent="start"
maxWidth="68%"
maxWidth="600px"
width='40%'
minWidth="15%"
position="relative"
flexDirection="column"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useEffect, useRef, useState } from 'react';

import {
GroupDTO,
IFeeds,
IMessageIPFS,
IMessageIPFSWithCID,
Expand All @@ -24,7 +25,7 @@ import {
walletToPCAIP10,
} from '../../../helpers';
import { useChatData, usePushChatSocket } from '../../../hooks';
import { Messagetype } from '../../../types';
import { IGroup, Messagetype } from '../../../types';
import { ThemeContext } from '../theme/ThemeProvider';
import { IChatTheme } from '../theme';

Expand Down Expand Up @@ -154,15 +155,24 @@ export const ChatViewList: React.FC<IChatViewListProps> = (
}
}, [messagesSinceLastConnection]);

// remove fetching group once stream comes
useEffect(() => {
if (Object.keys(groupInformationSinceLastConnection || {}).length) {
if (
chatFeed?.groupInformation?.chatId.toLowerCase() ===
groupInformationSinceLastConnection.chatId.toLowerCase()
) {
const updateChatFeed = chatFeed;
updateChatFeed.groupInformation = groupInformationSinceLastConnection;
setChatFeed(updateChatFeed);
(async()=>{
const updateChatFeed = chatFeed;
const group:IGroup | undefined = await getGroup({ searchText: chatId });
if (group || !!Object.keys(group || {}).length){
updateChatFeed.groupInformation = group! as GroupDTO ;

setChatFeed(updateChatFeed);
}

})();

}
}
}, [groupInformationSinceLastConnection]);
Expand Down Expand Up @@ -280,6 +290,7 @@ export const ChatViewList: React.FC<IChatViewListProps> = (
};

const ifBlurChat = () =>{

return !!(
chatFeed &&
chatFeed?.groupInformation &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import { MdCheckCircle, MdError } from 'react-icons/md';
import EmojiPicker, { EmojiClickData } from 'emoji-picker-react';
import GifPicker from 'gif-picker-react';
import { IFeeds } from '@pushprotocol/restapi';
import { GroupDTO, IFeeds } from '@pushprotocol/restapi';
import { ToastContainer } from 'react-toastify';

import { Section, Div, Span } from '../../reusables';
Expand Down Expand Up @@ -178,9 +178,16 @@ export const MessageInput: React.FC<MessageInputProps> = ({
chatFeed?.groupInformation?.chatId.toLowerCase() ===
groupInformationSinceLastConnection.chatId.toLowerCase()
) {
const updateChatFeed = chatFeed;
updateChatFeed.groupInformation = groupInformationSinceLastConnection;
setChatFeed(updateChatFeed);
(async()=>{
const updateChatFeed = chatFeed;
const group:IGroup | undefined = await getGroup({ searchText: chatId });
if (group || !!Object.keys(group || {}).length){
updateChatFeed.groupInformation = group! as GroupDTO ;

setChatFeed(updateChatFeed);
}

})();
}
}
}, [groupInformationSinceLastConnection]);
Expand Down

0 comments on commit 5dbc943

Please sign in to comment.