Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class based restapi migration for chat components #862

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3af1ca5
feat: changed all the old apis in chat to class component ones
KlausMikhaelson Nov 16, 2023
5db0221
fix: reverted type change
KlausMikhaelson Nov 16, 2023
1d49e23
fix: removed unnecessary code
KlausMikhaelson Nov 16, 2023
153336a
fix: fixed type error in fetch chat
KlausMikhaelson Nov 16, 2023
a4ab6cf
fix: fixed pagination
KlausMikhaelson Nov 18, 2023
de2bc6e
fix: added correct types and changed alias to pushUser
KlausMikhaelson Nov 18, 2023
393ffe9
fix: fixed message not loading if signer is passed and changed api of…
KlausMikhaelson Nov 18, 2023
15bce8e
fix: updated creategroup and update group api and added initializep…
KlausMikhaelson Nov 18, 2023
729f2b9
fix: updated get profile hook with a new one for chat
KlausMikhaelson Nov 20, 2023
ad73b15
fix: fixed add members with a new hook
KlausMikhaelson Nov 21, 2023
e3c1606
fix: made changes as per comments on pr
KlausMikhaelson Nov 21, 2023
d91bbac
fix: moved initialize user to chatdataprovider
KlausMikhaelson Nov 21, 2023
e8fa9cb
fix: removed unused code and connected profile
KlausMikhaelson Nov 22, 2023
a4e9870
fix: fixed content issue when adding new member and replaced to or fr…
KlausMikhaelson Nov 22, 2023
6397df9
fix: fixed
mishramonalisha76 Nov 23, 2023
2b91a52
fix: merging with main
mishramonalisha76 Nov 27, 2023
4738e1a
fix: fixed guest mode
mishramonalisha76 Nov 27, 2023
c035385
fix: chat profile migration
mishramonalisha76 Nov 29, 2023
d7f5ec0
fix: user initialisation code
mishramonalisha76 Nov 29, 2023
64ca399
fix: fixed
mishramonalisha76 Nov 30, 2023
39ce166
fix: fixed
mishramonalisha76 Nov 30, 2023
bdcdfc3
fix: fetched members of a group
mishramonalisha76 Nov 30, 2023
da7f545
fix: fixed
mishramonalisha76 Dec 1, 2023
bea7799
fix: fixing chat profile
mishramonalisha76 Dec 20, 2023
e6a7991
fix: migrated chat profile to new restapi
mishramonalisha76 Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
echo "\nRunning GIT hooks..."
yarn cleanbuild
yarn nx affected --target=lint
#yarn nx affected --target=test
yarn nx affected --target=test
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const ChatViewComponentTest = () => {
return (
<div>
<h2>Chat UI Test page</h2>
<CreateGroupModal onClose={()=>{console.log('in close')}} />
{/* <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='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68'
chatId='a5dad31b20c9aaf761221b57f6f0ab96b03a456525159378388e896475b1f943'
limit={10}
isConnected={true}
groupInfoModalBackground={MODAL_BACKGROUND_TYPE.OVERLAY}
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/sdk-frontend-react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export function App() {
<Web3Context.Provider value={{ account, active, library, chainId }}>
<SocketContext.Provider value={socketData}>
<AccountContext.Provider value={{ pgpPrivateKey, setSpaceId }}>
<ChatUIProvider env={env} theme={lightChatTheme} >
<ChatUIProvider signer={signer} env={env} theme={lightChatTheme} >
<SpacesUIProvider spaceUI={spaceUI} theme={customDarkTheme}>
<Routes>
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const ChatProfile: React.FC<IChatProfile> = ({
groupInfoModalPositionType = MODAL_POSITION_TYPE.GLOBAL,
}) => {
const theme = useContext(ThemeContext);
const { account, env } = useChatData();
const { account, env, pushUser } = useChatData();
const { getGroupByID } = useGetGroupByID();
const { fetchUserChatProfile } = useChatProfile();

Expand Down Expand Up @@ -110,7 +110,7 @@ export const ChatProfile: React.FC<IChatProfile> = ({
useEffect(() => {
if (!chatId) return;
fetchProfileData();
}, [chatId, account, env]);
}, [chatId, account, pushUser]);

if (chatId && style === 'Info') {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import {
pCAIP10ToWallet,
shortenText,
} from '../../../helpers';
import { formatTime } from '../../../helpers/timestamp';

const SenderMessageAddress = ({ chat }: { chat: IMessagePayload }) => {
const { account } = useContext(ChatDataContext);
const theme = useContext(ThemeContext);
return (
<>
{chat.fromCAIP10.split(':')[1] !== account && (
{(chat.fromDID).split(':')[1] !== account && (
<Span
theme={theme}
alignSelf="start"
Expand All @@ -53,7 +54,7 @@ const SenderMessageProfilePicture = ({ chat }: { chat: IMessagePayload }) => {
const [pfp, setPfp] = useState<string>('');
const getUserPfp = async () => {
const pfp = await getPfp({
account: chat.fromCAIP10.split(':')[1],
account: chat.fromDID.split(':')[1],
env: env,
});
if (pfp) {
Expand All @@ -62,10 +63,10 @@ const SenderMessageProfilePicture = ({ chat }: { chat: IMessagePayload }) => {
};
useEffect(() => {
getUserPfp();
}, [account, chat.fromCAIP10]);
}, [account, chat.fromDID]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets revert this back to .fromCAIP10, in this file

return (
<Section justifyContent="start" alignItems="start">
{chat.fromCAIP10.split(':')[1] !== account && (
{(chat.fromDID || chat.fromDID).split(':')[1] !== account && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat.fromDID || chat.fromDID aren't these 2 the same? what's the point of OR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks for pointing out will remove one

<Section alignItems="start">
{pfp && (
<Image
Expand Down Expand Up @@ -123,7 +124,7 @@ const MessageCard = ({
isGroup: boolean;
}) => {
const theme = useContext(ThemeContext);
const time = moment(chat.timestamp).format('hh:mm a');
const time = formatTime(chat.timestamp)
return (
<MessageWrapper chat={chat} isGroup={isGroup} maxWidth="70%">
<Section
Expand Down Expand Up @@ -347,7 +348,7 @@ export const ChatViewBubble = ({ decryptedMessagePayload }: { decryptedMessagePa
});
const [isGroup, setIsGroup] = useState<boolean>(false);
useEffect(() => {
if (decryptedMessagePayload.toDID.split(':')[0] === 'eip155') {
if ((decryptedMessagePayload.toDID).split(':')[0] === 'eip155') {
if (isGroup) {
setIsGroup(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ChatViewComponent: React.FC<IChatViewComponentProps> = (
verificationFailModalPosition = MODAL_POSITION_TYPE.GLOBAL,
} = options || {};

const { env, signer, account, pgpPrivateKey } = useChatData();
const { env, signer, account } = useChatData();

// const [conversationHash, setConversationHash] = useState<string>();

Expand Down Expand Up @@ -80,15 +80,15 @@ export const ChatViewComponent: React.FC<IChatViewComponentProps> = (
)}
</Section>
{/* )} */}
{(!signer && !(!!account && !!pgpPrivateKey) && !isConnected) && (
{(!signer && !account && !isConnected) && (
<Section flex="0 1 auto">
<Span>
You need to either pass signer or isConnected to send
messages{' '}
</Span>
</Section>
)}
{(messageInput && (!!signer || (!!account && !!pgpPrivateKey) || isConnected )) && (
{(messageInput && (!!signer || (!!account) || isConnected )) && (
<Section flex="0 1 auto" position='static'>
<MessageInput
onVerificationFail={onVerificationFail}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ApproveRequestBubble = ({
chatId,
setChatFeed,
}: IApproveRequestBubbleProps) => {
const { pgpPrivateKey } = useChatData();
const { pushUser } = useChatData();

const ApproveRequestText = {
GROUP: `You were invited to the group ${chatFeed?.groupInformation?.groupName}. Please accept to continue messaging in this group.`,
Expand All @@ -39,13 +39,7 @@ export const ApproveRequestBubble = ({

const handleApproveChatRequest = async () => {
try {
if (!pgpPrivateKey) {
return;
}

const response = await approveChatRequest({
chatId,
});
const response = await pushUser?.chat.accept(chatId);
if (response) {
const updatedChatFeed = { ...(chatFeed as IFeeds) };
updatedChatFeed.intent = response;
Expand Down
Loading