Skip to content

Commit

Permalink
fix: merge alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed Nov 11, 2023
2 parents b126ed6 + 33f6723 commit 3037c72
Show file tree
Hide file tree
Showing 140 changed files with 28,466 additions and 8,371 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"scripts": {
"prepare": "husky install",
"test:restapi": "cd packages/restapi && TS_NODE_PROJECT='./tsconfig.mocha.json' NODE_OPTIONS='--loader ts-node/esm' mocha -r ts-node/register 'tests/**/*.test.ts' --timeout 12000 --require tests/root.ts --serial",
"test:restapi": "cd packages/restapi && TS_NODE_PROJECT='./tsconfig.mocha.json' NODE_OPTIONS='--loader ts-node/esm' mocha -r ts-node/register 'tests/**/*.test.ts' --timeout 1200000 --require tests/root.ts --serial",
"cleanbuild": "rimraf ./dist && rimraf ./tmp"
},
"config": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"react-router-dom": "6.3.0",
"regenerator-runtime": "0.13.7",
"socket.io-client": "^4.5.2",
"styled-components": "^5.3.5",
"styled-components": "^6.0.8",
"tiny-invariant": "^1.2.0",
"ts-mocha": "^10.0.0",
"tslib": "^2.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/sdk-backend-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@pushprotocol/restapi": "0.0.1-alpha.50",
"@pushprotocol/restapi": "0.0.1-alpha.51",
"@pushprotocol/socket": "^0.5.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';
import { Web3Provider } from '@ethersproject/providers';
import { Chat, ITheme } from '@pushprotocol/uiweb';
import { SupportChat, ITheme } from '@pushprotocol/uiweb';
import { lightTheme } from '@pushprotocol/uiweb';
import { EnvContext, Web3Context } from './context';

Expand Down Expand Up @@ -31,10 +31,11 @@ export const ChatSupportTest = () => {
};

return (
<Chat
account={account}
//works as Chat as well as Support Chat
<SupportChat

signer={librarySigner}
supportAddress="0xD2A371cAFBE09333F6668229E4BD33196583c325"
supportAddress="0x6F7919412318E65109c5698bd0E640fc33DE2337"
apiKey="tAWEnggQ9Z.UaDBNjrvlJZx3giBTIQDcT8bKQo1O1518uF1Tea7rPwfzXv2ouV5rX9ViwgJUrXm"
env={env}
greetingMsg="How can i help you?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ const ChatTest = () => {
<Link to="/getGroupMemberStatus" className="nav-button">
CHAT.GETGROUPMEMBERSTATUS
</Link>
<Link to="/getChatMemberCountTest" className="nav-button">
CHAT.GetChatMemberCountTest
</Link>
<Link to="/getGroupInfoTest" className="nav-button">
CHAT.GetGroupInfoTest
</Link>
<Link to="/getGroupMembersTest" className="nav-button">
CHAT.GetGroupMembersTest
</Link>
<Link to="/searchGroups" className="nav-button">
CHAT.SEARCHGROUPS
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useState, useContext } from 'react';
import { Section, SectionItem, CodeFormatter, SectionButton } from '../components/StyledComponents';
import Loader from '../components/Loader';
import { EnvContext } from '../context';
import * as PushAPI from '@pushprotocol/restapi';

const GetChatMemberCountTest = () => {
const { env } = useContext<any>(EnvContext);
const [isLoading, setLoading] = useState(false);
const [chatId, setChatId] = useState<string>('');
const [totalMembersCount, setTotalMembersCount] = useState<PushAPI.ChatMemberCounts | null>(null);

const updateChatId = (e: React.ChangeEvent<HTMLInputElement>) => {
setChatId(e.target.value);
};

const fetchMemberCount = async () => {
try {
setLoading(true);
const counts = await PushAPI.chat.getChatMemberCount({ chatId, env });
setTotalMembersCount(counts);
} catch (error) {
console.error('Failed to fetch chat member count:', error);
} finally {
setLoading(false);
}
};

return (
<div>
<h2>Get Chat Member Count Test Page</h2>
<Loader show={isLoading} />
<Section>
<SectionItem>
<label>Chat ID:</label>
<input
type="text"
onChange={updateChatId}
value={chatId}
style={{ width: 400, height: 30 }}
/>
</SectionItem>
<SectionItem>
<SectionButton onClick={fetchMemberCount}>Fetch Member Count</SectionButton>
</SectionItem>
{totalMembersCount && (
<SectionItem>
<div>
<CodeFormatter>
{JSON.stringify(totalMembersCount, null, 2)}
</CodeFormatter>
</div>
</SectionItem>
)}
</Section>
</div>
);
};

export default GetChatMemberCountTest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { useState, useContext } from 'react';
import { EnvContext } from '../context';
import * as PushAPI from '@pushprotocol/restapi';
import Loader from '../components/Loader';
import { Section, SectionItem, CodeFormatter, SectionButton } from '../components/StyledComponents';

const GetGroupInfoTest = () => {
const { env } = useContext<any>(EnvContext);
const [chatId, setChatId] = useState('');
const [sendResponse, setSendResponse] = useState<any>('');
const [isLoading, setLoading] = useState(false);

const updateChatId = (e: React.ChangeEvent<HTMLInputElement>) => {
setChatId(e.target.value);
};

const fetchGroupInfo = async () => {
setLoading(true);
try {
const groupInfo = await PushAPI.chat.getGroupInfo({ chatId, env });
setSendResponse(groupInfo);
} catch (error) {
console.error('Error fetching group info:', error);
} finally {
setLoading(false);
}
};

return (
<div>
<h2>Get Group Info Test</h2>
<Loader show={isLoading} />
<Section>
<SectionItem>
<label htmlFor="chatId">Chat ID:</label>
<input
id="chatId"
type="text"
onChange={updateChatId}
value={chatId}
placeholder="Enter chat ID"
style={{ width: '100%', height: 30 }}
/>
</SectionItem>
<SectionItem>
<SectionButton onClick={fetchGroupInfo}>
Fetch Group Info
</SectionButton>
</SectionItem>
{sendResponse && (
<SectionItem>
<h3>Group Information:</h3>
<CodeFormatter>
{JSON.stringify(sendResponse, null, 2)}
</CodeFormatter>
</SectionItem>
)}
</Section>
</div>
);
};

export default GetGroupInfoTest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { useState, useContext, useEffect } from 'react';
import { Section, SectionItem, CodeFormatter, SectionButton } from '../components/StyledComponents';
import Loader from '../components/Loader';
import { EnvContext } from '../context';
import * as PushAPI from '@pushprotocol/restapi';

const GetGroupMembersTest = () => {
const { env } = useContext<any>(EnvContext);
const [isLoading, setLoading] = useState(false);
const [chatId, setChatId] = useState<string>('');
const [pageNumber, setPageNumber] = useState<number>(1);
const [pageSize, setPageSize] = useState<number>(20);
const [sendResponse, setSendResponse] = useState<any>('');


const updateChatId = (e: React.ChangeEvent<HTMLInputElement>) => {
setChatId(e.target.value);
};

const updatePageNumber = (e: React.ChangeEvent<HTMLInputElement>) => {
setPageNumber(parseInt(e.target.value));
};

const updatePageSize = (e: React.ChangeEvent<HTMLInputElement>) => {
setPageSize(parseInt(e.target.value));
};

const fetchGroupMembers = async () => {
setLoading(true);
try {
const result = await PushAPI.chat.getGroupMembers({
chatId,
page: pageNumber,
limit: pageSize,
env,
});
setSendResponse(result);
} catch (error) {
console.error('Failed to fetch group members:', error);
} finally {
setLoading(false);
}
};

// Fetch members when component mounts
useEffect(() => {
fetchGroupMembers();
}, []);

return (
<div>
<h2>Get Group Members Test Page</h2>
<Loader show={isLoading} />
<Section>
<SectionItem>
<label>Chat ID:</label>
<input
type="text"
onChange={updateChatId}
value={chatId}
placeholder="Enter chat ID"
style={{ width: '100%', height: 30 }}
/>
</SectionItem>
<SectionItem>
<label>Page Number:</label>
<input
type="number"
onChange={updatePageNumber}
value={pageNumber}
style={{ width: '100%', height: 30 }}
/>
</SectionItem>
<SectionItem>
<label>Page Size:</label>
<input
type="number"
onChange={updatePageSize}
value={pageSize}
style={{ width: '100%', height: 30 }}
/>
</SectionItem>
<SectionItem>
<SectionButton onClick={fetchGroupMembers}>Fetch Group Members</SectionButton>
</SectionItem>
{sendResponse && (
<SectionItem>
<CodeFormatter>
{JSON.stringify(sendResponse, null, 2)}
</CodeFormatter>
</SectionItem>
)}
</Section>
</div>
);
};

export default GetGroupMembersTest;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled from 'styled-components';

import { Section } from '../components/StyledComponents';
import { CreateGroupModal } from "@pushprotocol/uiweb";
import { ChatViewComponent } from '@pushprotocol/uiweb';
import { CreateGroupModal, MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE } from "@pushprotocol/uiweb";
import { ChatView } from '@pushprotocol/uiweb';

const ChatViewComponentTest = () => {
const chatFilterList = [
Expand All @@ -15,7 +15,17 @@ const ChatViewComponentTest = () => {
<h2>Chat UI Test page</h2>
<CreateGroupModal onClose={()=>{console.log('in close')}} />
<ChatViewComponentCard>
<ChatViewComponent onGetTokenClick={() => console.log("BOIIII RETURNNNSSSSS")} chatId='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68' limit={10} isConnected={true} />
<CreateGroupModal onClose={()=>{console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/>

<ChatView
onVerificationFail={() => console.log("BOIIII RETURNNNSSSSS")}
chatId='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68'
limit={10}
isConnected={true}
groupInfoModalBackground={MODAL_BACKGROUND_TYPE.OVERLAY}
groupInfoModalPositionType={MODAL_POSITION_TYPE.RELATIVE}
verificationFailModalPosition={MODAL_POSITION_TYPE.RELATIVE}
/>
</ChatViewComponentCard>
</div>
);
Expand All @@ -24,7 +34,8 @@ const ChatViewComponentTest = () => {
export default ChatViewComponentTest;

const ChatViewComponentCard = styled(Section)`
height: 60vh;
height: 80vh;
position:relative;
`;
//c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e
//4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68
Loading

0 comments on commit 3037c72

Please sign in to comment.