diff --git a/.github/workflows/auto_add_project.yml b/.github/workflows/auto_add_project.yml new file mode 100644 index 0000000000..b86ff18dcb --- /dev/null +++ b/.github/workflows/auto_add_project.yml @@ -0,0 +1,16 @@ +name: Auto-add issues to org project + +on: + issues: + types: + - opened + +jobs: + add-to-project: + name: Auto-add issues to org project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v0.5.0 + with: + project-url: https://github.com/orgs/ethereum-push-notification-service/projects/10 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} diff --git a/ledger.manifest.json b/ledger.manifest.json deleted file mode 100644 index bf06ddba99..0000000000 --- a/ledger.manifest.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "id": "PUSH", - "name": "PUSH", - "url": "https://platform.apps.ledger.com/app/dapp-browser?dappName=PUSH&nanoApp=PUSH&url=https%3A%2F%2Fapp.push.org%2F%3Fembed%3Dtrue", - "homepageUrl": "https://push.org/", - "icon": "https://backend-dev.epns.io/assets/pushlogo.png", - "platform": "all", - "apiVersion": "0.0.1", - "manifestVersion": "1", - "branch": "stable", - "categories": [ - "staking", - "defi", - "options" - ], - "currencies": [ - "ethereum", - "dai" - ], - "content": { - "shortDescription": { - "en": "The Communication Protocol of Web3" - }, - "description": { - "en": "Push Protocol is a web3 communication network, enabling cross-chain notifications and messaging for dapps, wallets, and services." - } - }, - "permissions": [], - "domains": [ - "https://*" - ] -} \ No newline at end of file diff --git a/package.json b/package.json index 3da1e12a06..ad308fc6ce 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,9 @@ "@mui/icons-material": "^5.8.4", "@mui/lab": "^5.0.0-alpha.72", "@mui/material": "^5.5.0", - "@pushprotocol/ledgerlive": "latest", - "@pushprotocol/restapi": "1.4.41", + "@pushprotocol/restapi": "1.4.45", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "1.1.19", + "@pushprotocol/uiweb": "1.1.23", "@reduxjs/toolkit": "^1.7.1", "@testing-library/dom": "^9.0.1", "@testing-library/jest-dom": "^4.2.4", diff --git a/src/assets/PushSnaps/UDIcon.svg b/src/assets/PushSnaps/UDIcon.svg new file mode 100644 index 0000000000..6d2556e8f1 --- /dev/null +++ b/src/assets/PushSnaps/UDIcon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/MetamaskSnap/InstallMetamaskSnapModal.tsx b/src/components/MetamaskSnap/InstallMetamaskSnapModal.tsx index d9d1d08de4..9af39d7238 100644 --- a/src/components/MetamaskSnap/InstallMetamaskSnapModal.tsx +++ b/src/components/MetamaskSnap/InstallMetamaskSnapModal.tsx @@ -11,6 +11,7 @@ import { Button } from 'components/SharedStyling'; import Metamask from 'assets/PushSnaps/metamasksnap.svg'; import PushIcon from 'assets/PushSnaps/PushIcon.svg'; import VersoIcon from 'assets/PushSnaps/VersoIcon.svg'; +import UDIcon from 'assets/PushSnaps/UDIcon.svg'; import AppStoreQRCode from 'assets/PushSnaps/AppStoreQRCode.svg'; import PlayStoreQRCode from 'assets/PushSnaps/PlayStoreQRCode.svg'; import AppleIcon from 'assets/PushSnaps/AppleIcon.svg'; @@ -115,6 +116,29 @@ const InstallMetamaskSnapModal = ({ + + + + + Unstoppable Domains + + + + + App store + + + Play store + + + diff --git a/src/components/chat/w2wChat/chatBox/ChatBox.tsx b/src/components/chat/w2wChat/chatBox/ChatBox.tsx index 88c1fe4594..a1dd9210cf 100644 --- a/src/components/chat/w2wChat/chatBox/ChatBox.tsx +++ b/src/components/chat/w2wChat/chatBox/ChatBox.tsx @@ -10,52 +10,43 @@ import * as PushAPI from '@pushprotocol/restapi'; import 'font-awesome/css/font-awesome.min.css'; import { CID } from 'ipfs-http-client'; import { BsDashLg } from 'react-icons/bs'; -import { MdCheckCircle, MdError, MdOutlineArrowBackIos } from 'react-icons/md'; +import { MdOutlineArrowBackIos } from 'react-icons/md'; import ScrollToBottom from 'react-scroll-to-bottom'; import { useClickAway } from 'react-use'; import styled, { useTheme } from 'styled-components'; import { produce } from 'immer'; - +import { ChatViewList, MessageInput } from '@pushprotocol/uiweb'; // Internal Components import { ReactComponent as Info } from 'assets/chat/group-chat/info.svg'; import { ReactComponent as InfoDark } from 'assets/chat/group-chat/infodark.svg'; import { ReactComponent as More } from 'assets/chat/group-chat/more.svg'; import { ReactComponent as MoreDark } from 'assets/chat/group-chat/moredark.svg'; import videoCallIcon from 'assets/icons/videoCallIcon.svg'; -import LoaderSpinner, { LOADER_SPINNER_TYPE, LOADER_TYPE } from 'components/reusables/loaders/LoaderSpinner'; +import LoaderSpinner, { LOADER_TYPE } from 'components/reusables/loaders/LoaderSpinner'; import { ButtonV2, ImageV2, ItemHV2, ItemVV2, SpanV2 } from 'components/reusables/SharedStylingV2'; import Tooltip from 'components/reusables/tooltip/Tooltip'; import { Content } from 'components/SharedStyling'; import { ChatUserContext } from 'contexts/ChatUserContext'; -import * as w2wHelper from 'helpers/w2w/'; -import { - checkIfChatExist, - fetchInbox -} from 'helpers/w2w/user'; +import { checkIfChatExist } from 'helpers/w2w/user'; import { useAccount, useDeviceWidthCheck } from 'hooks'; import { useResolveWeb3Name } from 'hooks/useResolveWeb3Name'; import useToast from 'hooks/useToast'; import { Context } from 'modules/chat/ChatModule'; -import { AppContext as ContextType, Feeds, MessageIPFS } from 'types/chat'; +import { AppContext as ContextType } from 'types/chat'; import HandwaveIcon from '../../../../assets/chat/handwave.svg'; -import { caip10ToWallet, walletToCAIP10 } from '../../../../helpers/w2w'; -import { checkIfGroup, getGroupImage, getIntentMessage } from '../../../../helpers/w2w/groupChat'; -import { MessagetypeType } from '../../../../types/chat'; -import Chats from '../chats/Chats'; -import Typebar from '../TypeBar/Typebar'; -import { HeaderMessage } from './HeaderMessage'; +import { caip10ToWallet } from '../../../../helpers/w2w'; +import { checkIfGroup, getGroupImage } from '../../../../helpers/w2w/groupChat'; + import { AppContext } from 'contexts/AppContext'; import { AppContextType } from 'types/context'; // Internal Configs import { appConfig } from 'config'; import GLOBALS, { device } from 'config/Globals'; -import { getChats } from 'services'; import { VideoCallContext } from 'contexts/VideoCallContext'; // Constants const INFURA_URL = appConfig.infuraApiUrl; -const chatsFetchedLimit = 15; const Alert = React.forwardRef(function Alert(props, ref) { return ( @@ -69,48 +60,22 @@ const Alert = React.forwardRef(function Alert(props, }); const ChatBox = ({ showGroupInfoModal }): JSX.Element => { - const { - currentChat, - viewChatBox, - receivedIntents, - inbox, - messages, - activeTab, - setActiveTab, - setMessages, - setChat, - setInbox, - setHasUserBeenSearched, - setReceivedIntents, - setBlockedLoading, - }: ContextType = useContext(Context); - const { web3NameList }:AppContextType=useContext(AppContext); - const [chatMeta, setChatMeta] = useState(null); - - const [newMessage, setNewMessage] = useState(''); - const { chainId, account, provider } = useAccount(); + const { currentChat, viewChatBox, receivedIntents, activeTab, setChat }: ContextType = + useContext(Context); + const { web3NameList }: AppContextType = useContext(AppContext); + + const { account } = useAccount(); const [Loading, setLoading] = useState(true); - const [messageBeingSent, setMessageBeingSent] = useState(false); const [imageSource, setImageSource] = useState(''); const [openReprovalSnackbar, setOpenSuccessSnackBar] = useState(false); const [SnackbarText, setSnackbarText] = useState(''); const [isGroup, setIsGroup] = useState(false); const [showGroupInfo, setShowGroupInfo] = useState(false); const groupInfoRef = useRef(null); - const { connectedUser, setConnectedUser, createUserIfNecessary } = useContext(ChatUserContext); + const { connectedUser } = useContext(ChatUserContext); const { videoObject } = useContext(VideoCallContext); - - const listInnerRef = useRef(null); - const topRef = useRef(null); - const bottomRef = useRef(null); - const [chatsLoading, setChatsLoading] = useState(true); - const [lastThreadHashFetched, setLastThreadHashFetched] = useState(null); - const [wasLastListPresent, setWasLastListPresent] = useState(false); - const chatBoxToast = useToast(); const theme = useTheme(); const isMobile = useDeviceWidthCheck(600); - let showTime = false; - let time = ''; useClickAway(groupInfoRef, () => setShowGroupInfo(false)); @@ -118,8 +83,8 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { useResolveWeb3Name(!isGroup ? currentChat?.wallets?.split(',')[0].toString() : null); // get web3 name - let ensName='' - if(!isGroup && currentChat?.wallets?.split(',')[0].toString()){ + let ensName = ''; + if (!isGroup && currentChat?.wallets?.split(',')[0].toString()) { const walletLowercase = caip10ToWallet(currentChat?.wallets?.split(',')[0].toString())?.toLowerCase(); const checksumWallet = ethers.utils.getAddress(walletLowercase); ensName = web3NameList[checksumWallet]; @@ -135,90 +100,15 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { } }, [ensName]); - const onScroll = async () => { - if (listInnerRef.current) { - const { scrollTop } = listInnerRef.current; - if (scrollTop === 0) { - // This will be triggered after hitting the first element. - // pagination - // addDom(); - - //scroll item - // let content = document.getElementById('loop'); - let content = listInnerRef.current; - let curScrollPos = content.scrollTop; - let oldScroll = content.scrollHeight - content.clientHeight; - - await getChatCall(); - - let newScroll = content.scrollHeight - content.clientHeight; - content.scrollTop = curScrollPos + (newScroll - oldScroll); - } - } - }; - - const scrollToBottom = (behavior) => { - bottomRef?.current?.scrollIntoView(!behavior ? true : { behavior: 'smooth' }); - }; - useEffect(() => { - if (messages.length <= chatsFetchedLimit) scrollToBottom(null); - }, [messages]); - - const getChatCall = async ( - wasLastListPresentProp = wasLastListPresent, - messagesProp = messages, - lastThreadHashFetchedProp = lastThreadHashFetched - ) => { - if (!connectedUser) return; - if (wasLastListPresentProp && !lastThreadHashFetchedProp) return; - setChatsLoading(true); - // scrollToNext(); - const { chatsResponse, lastThreadHash, lastListPresent } = await getChats({ - account, - pgpPrivateKey: connectedUser.privateKey, - chatId: currentChat?.did || currentChat?.groupInformation?.chatId, - threadHash: lastThreadHashFetchedProp!, - limit: chatsFetchedLimit, - }); - - // remove this custom decryption after SDK issue is resolved in future - const promiseArrToDecryptMsg = []; - chatsResponse.forEach((chat) => - promiseArrToDecryptMsg.push( - w2wHelper.decryptMessages({ - savedMsg: chat, - connectedUser, - account, - currentChat, - inbox, - }) - ) - ); - const decryptedMsgArr = await Promise.all(promiseArrToDecryptMsg); - decryptedMsgArr.sort((a, b) => { - return a.timestamp! > b.timestamp! ? 1 : -1; - }); - - setMessages([...decryptedMsgArr, ...messagesProp]); - setLastThreadHashFetched(lastThreadHash); - setWasLastListPresent(lastListPresent); - setChatsLoading(false); - }; - - useEffect(() => { - setWasLastListPresent(false); - setLastThreadHashFetched(null); setIsGroup(false); setShowGroupInfo(false); - setMessages([]); if (currentChat) { setIsGroup(checkIfGroup(currentChat)); // We only delete the messages once the user clicks on another chat. The user could click multiple times on the same chat and it would delete the previous messages // even though the user was still on the same chat. const image = getGroupImage(currentChat); - getChatCall(false, [], null); try { CID.parse(image); // Will throw exception if invalid CID setImageSource(INFURA_URL + `${image}`); @@ -240,209 +130,6 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { if (currentChat?.wallets) return caip10ToWallet(currentChat?.wallets?.split(',')[0].toString()); }; - const fetchInboxApi = async (): Promise => { - const inboxes: Feeds[] = await fetchInbox({connectedUser}); - setInbox(inboxes); - return inboxes?.find((x) => x.wallets.split(':')[1]?.toLowerCase() === currentChat.wallets.split(':')[1]?.toLowerCase()); - }; - - const sendMessage = async ({ - message, - messageType, - }: { - message: string; - messageType: MessagetypeType; - }): Promise => { - setMessageBeingSent(true); - - try { - let createdUser; - if (!connectedUser.publicKey) { - createdUser = await createUserIfNecessary(); - } - const signer = await provider.getSigner(); - - const sendResponse = await PushAPI.chat.send({ - messageContent: message, - messageType: messageType, - receiverAddress: isGroup ? currentChat.groupInformation?.chatId : currentChat?.wallets, - signer: signer!, - pgpPrivateKey: connectedUser?.privateKey || createdUser?.privateKey, - env: appConfig.appEnv, - }); - - if (typeof sendResponse !== 'string') { - sendResponse.messageContent = message; - const updatedCurrentChat = currentChat; - updatedCurrentChat.msg = sendResponse; - setChat(updatedCurrentChat); - setNewMessage(''); - setMessages([...messages, sendResponse]); - - setTimeout(() => { - setMessageBeingSent(false); - }, 1) - } - - } catch (error) { - chatBoxToast.showMessageToast({ - toastTitle: 'Error', - toastMessage: 'Cannot send Message, Try again later', - toastType: 'ERROR', - getToastIcon: (size) => ( - - ), - }); - - setMessageBeingSent(false); - } - }; - - useEffect(() => { - if (messageBeingSent == false) { - setTimeout(() => { - scrollToBottom(null); - }, 10); - } - }, [messageBeingSent]); - - async function resolveThreadhash(): Promise { - setLoading(true); - // If the user is not registered in the protocol yet, his did will be his wallet address - const didOrWallet: string = connectedUser.wallets.split(':')[1]; - let intents = await PushAPI.chat.requests({ account: didOrWallet!, env: appConfig.appEnv, toDecrypt: true, pgpPrivateKey:connectedUser.privateKey }); - setReceivedIntents(intents); - setLoading(false); - } - - async function ApproveIntent(status: string): Promise { - setMessageBeingSent(true); - let updatedIntent: any; - try { - let createdUser; - if (!connectedUser.publicKey) { - createdUser = await createUserIfNecessary(); - } - const signer = await provider.getSigner(); - updatedIntent = await PushAPI.chat.approve({ - status: 'Approved', - signer: signer!, - senderAddress: isGroup ? currentChat.groupInformation?.chatId : currentChat.intentSentBy, - pgpPrivateKey: connectedUser?.privateKey || createdUser?.privateKey, - env: appConfig.appEnv, - }); - - let activeChat = currentChat; - activeChat.intent = updatedIntent.data; - setChat(activeChat); - - // displaying toast according to status - if (status === 'Approved') { - chatBoxToast.showMessageToast({ - toastTitle: 'Success', - toastMessage: 'Request approved', - toastType: 'SUCCESS', - getToastIcon: (size) => ( - - ), - }); - } - - setActiveTab(0); - await resolveThreadhash(); - setMessageBeingSent(false); - } catch (error) { - chatBoxToast.showMessageToast({ - toastTitle: 'Error', - toastMessage: 'Cannot approve intent, Try again later', - toastType: 'ERROR', - getToastIcon: (size) => ( - - ), - }); - } - } - - const sendIntent = async ({ - message, - messageType, - }: { - message: string; - messageType: MessagetypeType; - }): Promise => { - let user; - try { - setMessageBeingSent(true); - if ( - currentChat.intent === null || - currentChat.intent === '' || - !currentChat.intent?.toLowerCase().includes(currentChat.wallets.split(':')[1]?.toLowerCase()) - ) { - let createdUser; - if (!connectedUser.publicKey) { - createdUser = await createUserIfNecessary(); - } - const signer = await provider.getSigner(); - const sendResponse = await PushAPI.chat.send({ - messageContent: message, - messageType: messageType, - receiverAddress: currentChat?.wallets.split(':')[1], - signer: signer!, - pgpPrivateKey: connectedUser.privateKey || createdUser?.privateKey, - env: appConfig.appEnv, - }); - - if (typeof sendResponse !== 'string') { - // We store the message in state decrypted so we display to the user the intent message - sendResponse.messageContent = message; - setNewMessage(''); - let result = await fetchInboxApi(); - result.msg.messageContent = message; - setChat(result); - chatBoxToast.showMessageToast({ - toastTitle: 'Success', - toastMessage: 'Chat Request Sent', - toastType: 'SUCCESS', - getToastIcon: (size) => ( - - ), - }); - setMessageBeingSent(false); - } - } - - setHasUserBeenSearched(false); - setActiveTab(0); - } catch (error) { - chatBoxToast.showMessageToast({ - toastTitle: 'Error', - toastMessage: 'Cannot send request, Try again later', - toastType: 'ERROR', - getToastIcon: (size) => ( - - ), - }); - setMessageBeingSent(false); - } finally { - setMessageBeingSent(false); - } - }; - const handleCloseSuccessSnackbar = (event?: React.SyntheticEvent | Event, reason?: string): void => { if (reason === 'clickaway') { return; @@ -451,8 +138,6 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { }; const startVideoCallHandler = async () => { - console.log("CURRENT CHAT", currentChat); - videoObject?.setData((oldData) => { return produce(oldData, (draft) => { draft.local.address = account; @@ -463,7 +148,6 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { }); }; - const InfoMessages = [ { id: 1, content: 'You can send up to 10 group requests in alpha' }, // { id: 2, content: 'You can send a chat request to anyone including non-whitelisted users' }, @@ -604,21 +288,26 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { {/* Video call button */} - {!isGroup && - - - - } + {!isGroup && ( + + + + + + )} {currentChat.groupInformation && ( setShowGroupInfo(!showGroupInfo)}> @@ -639,104 +328,21 @@ const ChatBox = ({ showGroupInfoModal }): JSX.Element => { )} - - {/* style={{overflow: "scroll",backgroundColor:'red'}} */} - {/* */} - {Loading ? ( - - - - ) : ( - <> - {chatsLoading && ( - - - - )} -
- {messages?.map((msg, i) => { - //const isLast = i === messages.length - 1 - //const noTail = !isLast && messages[i + 1]?.fromDID === msg.fromDID - - showTime = false; - if (i >= 0) { - const duration = new Date(messages[i]?.timestamp); - const dateString = duration.toDateString(); - if (dateString !== time || i === 0) { - showTime = true; - time = dateString; - } - } - return ( -
- {!showTime ? null : ( - - )} - - -
- ); - })} -
- - {checkIfChatExist({ chats:receivedIntents, currentChat, connectedUser, isGroup }) && ( - ApproveIntent('Approved')} - isGroup={isGroup} - /> - )} - + + {(!!currentChat || !!Object.keys(currentChat || {}).length) && ( + )} - {/*
*/} -
- - {checkIfChatExist({ chats:receivedIntents, currentChat, connectedUser,isGroup }) ? null : ( + {checkIfChatExist({ chats: receivedIntents, currentChat, connectedUser, isGroup }) ? null : ( <> - + + {(!!currentChat || !!Object.keys(currentChat || {}).length) && ( + + )} + )} @@ -750,58 +356,82 @@ const SpinnerWrapper = styled.div` margin-top: 20px; height: ${(props) => props.height || '90px'}; `; +const MessageInputWrapper = styled.div` + width: 98%; + display: flex; + justify-content: center; + position: absolute; + bottom: 8px; -const MessageContainer = styled(ItemVV2)` + z-index: 99; +`; +const ChatContainer = styled.div` + overflow-x: hidden; align-items: unset; display: block; justify-content: flex-start; position: absolute; - top: 65px; - bottom: 66px; + top: 20px; + bottom: 0px; left: 0; right: 0; margin: 0; width: 100%; - height: calc(100% - 140px); - overflow-x: none; - overflow-y: scroll; +`; +const MessageContainer = styled(ItemVV2)` + align-items: center; + display: flex; + flex-direction: column; + justify-content: flex-start; + position: absolute; + padding: 40px 20px; + top: 40px; + // bottom: 150px; + // left: 0; + // right: 0; + // margin: 0; + width: 95%; + height: 80%; + // max-height: 20%; + overflow-x: hidden; + // overflow-y: scroll; // background: red; - &::-webkit-scrollbar-track { - background-color: ${(props) => props.theme.scrollBg}; - border-radius: 10px; - } - - &::-webkit-scrollbar { - background-color: ${(props) => props.theme.scrollBg}; - width: 5px; - } - - @media (max-width: 768px) { - padding: 0px 0px 0px 0px; - - &::-webkit-scrollbar-track { - background-color: none; - border-radius: 9px; - } - - &::-webkit-scrollbar { - background-color: none; - width: 4px; - } - } - - &::-webkit-scrollbar-thumb { - border-radius: 10px; - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.44, #cf1c84), - color-stop(0.72, #cf1c84), - color-stop(0.86, #cf1c84) - ); - } + // &::-webkit-scrollbar-track { + // background-color: ${(props) => props.theme.scrollBg}; + // border-radius: 10px; + // } + + // &::-webkit-scrollbar { + // background-color: ${(props) => props.theme.scrollBg}; + // width: 5px; + // } + + // @media (max-width: 768px) { + // padding: 0px 0px 0px 0px; + + // &::-webkit-scrollbar-track { + // background-color: none; + // border-radius: 9px; + // } + + // &::-webkit-scrollbar { + // background-color: none; + // width: 4px; + // } + // } + + // &::-webkit-scrollbar-thumb { + // border-radius: 10px; + // background-image: -webkit-gradient( + // linear, + // left top, + // left bottom, + // color-stop(0.44, #cf1c84), + // color-stop(0.72, #cf1c84), + // color-stop(0.86, #cf1c84) + // ); + // } `; const GroupInfo = styled(ItemHV2)` diff --git a/src/components/chat/w2wChat/chatBox/HeaderMessage.tsx b/src/components/chat/w2wChat/chatBox/HeaderMessage.tsx deleted file mode 100644 index aeddaec8ab..0000000000 --- a/src/components/chat/w2wChat/chatBox/HeaderMessage.tsx +++ /dev/null @@ -1,134 +0,0 @@ -// React + Web3 Essentials -import React from 'react'; - -// External Packages -import styled from 'styled-components'; - -// Internal Components -import Lock from 'assets/Lock.png'; -import LockSlash from 'assets/LockSlash.png'; -import { Item } from 'primaries/SharedStyling'; -import { ItemHV2 } from 'components/reusables/SharedStylingV2'; -import { AppContext, MessageIPFSWithCID } from 'types/chat'; -import { Context } from 'modules/chat/ChatModule'; - -type HeaderMessageType = { - time?: string; - isGroup?: boolean; - index?: number; - messages?: MessageIPFSWithCID[]; -}; - -export const HeaderMessage = ({ time, isGroup, index, messages }: HeaderMessageType) => { - const { currentChat }: AppContext = React.useContext(Context); - - let intents = currentChat?.intent?.split('+'); - return ( - <> - - {time} - - {!isGroup && index === 0 && ( - <> - {intents?.length === 2 && ( - - - Messages are end-to-end encrypted. Only users in this chat can view or listen to them. - - {' '} - Click to learn more. - - - )} - {intents?.length === 1 && ( - - - Messages are not encrypted till the user accepts the chat request. - - )} - - )} - - {isGroup && (index === 0 || (messages && messages?.length === 0)) && ( - - - {currentChat?.groupInformation?.isPublic - ? 'Messages are not encrypted.' - : 'Messages are end-to-end encrypted. Only users in this chat can view or listen to them.'} - - {' '} - Click to learn more. - - - )} - - - {!isGroup && messages && messages?.length === 0 && ( - - - - Messages are not encrypted till the user accepts the chat request. - - - - This is your first conversation with recipient.

Start the conversation by sending a message. -
-
- )} - - ); -}; - -const ItemText = styled.div` - color: ${(props) => props.theme.default.secondaryColor}; - max-width: 556px; - font-weight: 400; - font-size: 13px; - line-height: 130%; - background-color: ${(props) => props.theme.default.bg}; - padding: 10px; - border-radius: 14px; - text-align: center; - margin-bottom: 10px; - - @media (max-width: 1250px) { - width: 70%; - } - - @media (max-width: 771px) { - width: 80%; - } -`; - -const MessageTime = styled(ItemHV2)` - width: 100%; - font-size: 11px; - color: ${(props) => props.theme.default.secondaryColor}; - margin: 15px 0px; -`; - -const FirstTime = styled(ItemHV2)` - width: 100%; - font-size: 13px; - color: ${(props) => props.theme.default.secondaryColor}; - margin: 15px 0px; -`; - -const ItemLink = styled.a` - color: ${(props) => props.theme.default.secondaryColor}; - text-decoration: none; - cursor: pointer; -`; - -const Image = styled.img` - width: 10px; - margin-right: 5px; - position: relative; - bottom: -2px; -`; diff --git a/src/components/chat/w2wChat/groupChat/createGroup/AddWalletContent.tsx b/src/components/chat/w2wChat/groupChat/createGroup/AddWalletContent.tsx index a8eb8d374a..d021b60510 100644 --- a/src/components/chat/w2wChat/groupChat/createGroup/AddWalletContent.tsx +++ b/src/components/chat/w2wChat/groupChat/createGroup/AddWalletContent.tsx @@ -209,8 +209,8 @@ export const AddWalletContent = ({ fontSize="14px" > {groupMembers - ? `0${memberList?.length + groupMembers?.length} / 09 Members` - : `0${memberList?.length} / 09 Members`} + ? `0${memberList?.length + groupMembers?.length} / 5000 Members` + : `0${memberList?.length} / 5000 Members`} diff --git a/src/config/config-dev.js b/src/config/config-dev.js index 441f88c1e5..184b83523c 100644 --- a/src/config/config-dev.js +++ b/src/config/config-dev.js @@ -70,7 +70,7 @@ export const config = { ios: 'https://discord.gg/pushprotocol', android: 'https://play.google.com/store/apps/details?gl=US&hl=en&id=io.epns.epnsstaging', extension: 'https://chrome.google.com/webstore/detail/epns-staging-protocol-alp/bjiennpmhdcandkpigcploafccldlakj', - howto: 'https://docs.epns.io', + howto: 'https://push.org/docs', }, } diff --git a/src/config/config-localhost.js b/src/config/config-localhost.js index a95046ba2f..6e92ccbc76 100644 --- a/src/config/config-localhost.js +++ b/src/config/config-localhost.js @@ -65,7 +65,7 @@ export const config = { ios: 'https://discord.gg/pushprotocol', android: 'https://play.google.com/store/apps/details?gl=US&hl=en&id=io.epns.epnsstaging', extension: 'https://chrome.google.com/webstore/detail/epns-staging-protocol-alp/bjiennpmhdcandkpigcploafccldlakj', - howto: 'https://docs.epns.io', + howto: 'https://push.org/docs', }, }; diff --git a/src/config/config-prod.js b/src/config/config-prod.js index 7403016e7f..050efab953 100644 --- a/src/config/config-prod.js +++ b/src/config/config-prod.js @@ -69,7 +69,7 @@ export const config = { ios: 'https://apps.apple.com/app/ethereum-push-service-epns/id1528614910', android: 'https://play.google.com/store/apps/details?id=io.epns.epns', extension: 'https://chrome.google.com/webstore/detail/epns-protocol-beta/lbdcbpaldalgiieffakjhiccoeebchmg', - howto: 'https://docs.epns.io', + howto: 'https://push.org/docs', }, }; diff --git a/src/config/config-staging.js b/src/config/config-staging.js index edadfcf376..7792006c97 100644 --- a/src/config/config-staging.js +++ b/src/config/config-staging.js @@ -36,7 +36,7 @@ export const config = { * Core Network Related Data */ coreContractChain: 11155111, //the chain id of the network which the core contract relies on - coreRPC: 'https://sepolia.infura.io/v3/5524d420b29f4f7a8d8d2f582a0d43f7', + coreRPC: 'https://sepolia.infura.io/v3/49f638cc25a94ddb86b7aefd612f11ab', mainnetCoreRPC: "https://mainnet.infura.io/v3/4ff53a5254144d988a8318210b56f47a", mainnetCoreContractChain: 1, aliasRPC: { @@ -71,7 +71,7 @@ export const config = { ios: 'https://discord.gg/pushprotocol', android: 'https://play.google.com/store/apps/details?gl=US&hl=en&id=io.epns.epnsstaging', extension: 'https://chrome.google.com/webstore/detail/epns-staging-protocol-alp/bjiennpmhdcandkpigcploafccldlakj', - howto: 'https://docs.epns.io', + howto: 'https://push.org/docs', }, } diff --git a/src/connectors.ts b/src/connectors.ts index 19b799ade3..a5cba6ab00 100644 --- a/src/connectors.ts +++ b/src/connectors.ts @@ -2,7 +2,6 @@ // // import { InjectedConnector } from '@web3-react/injected-connector'; // import { WalletConnectConnector } from '@web3-react/walletconnect-connector'; // import { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect-v2'; -// import { LedgerHQFrameConnector } from '@pushprotocol/ledgerlive'; // import { LedgerConnector } from '@web3-react/ledger-connector'; // import { TrezorConnector } from '@web3-react/trezor-connector'; // import { initializeConnector } from '@web3-react/core'; @@ -25,9 +24,6 @@ // // export const injected = new InjectedConnector({ supportedChainIds: SUPPORTED_CHAIN_IDS }); -// // Only receive messages from platform.apps.ledger.com -// export const ledgerLiveConnector = new LedgerHQFrameConnector(); - // const [mainnet, ...optionalChains] = Object.keys(CHAIN_DETAILS).map(Number); // // export const [walletConnectV2, hooks] = initializeConnector( diff --git a/src/contexts/ChatUserContext.tsx b/src/contexts/ChatUserContext.tsx index 39b688bdfc..d2210c3ccd 100644 --- a/src/contexts/ChatUserContext.tsx +++ b/src/contexts/ChatUserContext.tsx @@ -15,6 +15,8 @@ const ChatUserContextProvider = (props) => { const [connectedUser, setConnectedUser] = useState(); const { account, provider } = useAccount(); + + //this blocked loading is a modal which shows during the PGP keys generation time const [blockedLoading, setBlockedLoading] = useState({ enabled: false, diff --git a/src/helpers/w2w/groupChat.ts b/src/helpers/w2w/groupChat.ts index 1ee99d0288..13a9c1e1b8 100644 --- a/src/helpers/w2w/groupChat.ts +++ b/src/helpers/w2w/groupChat.ts @@ -135,22 +135,27 @@ export const updateGroup = async(options:UpdateGroupType) => { export const rearrangeMembers = (currentChat,connectedUser) => { - currentChat?.groupInformation?.members.sort(x => (x?.isAdmin) ? -1 : 1); - currentChat?.groupInformation?.members.some( - (member, idx) => - member?.wallet?.toLowerCase() == currentChat?.groupInformation?.groupCreator?.toLowerCase() && - currentChat?.groupInformation?.members.unshift( - currentChat?.groupInformation?.members.splice(idx, 1)[0] - ) - ); - currentChat?.groupInformation?.members.some( - (member, idx) => - member?.wallet?.toLowerCase() == connectedUser.wallets?.toLowerCase() && - currentChat?.groupInformation?.members.unshift( - currentChat?.groupInformation?.members.splice(idx, 1)[0] - ) - ); - return currentChat; + console.log(currentChat) + if(currentChat){ + currentChat?.groupInformation?.members.sort(x => (x?.isAdmin) ? -1 : 1); + currentChat?.groupInformation?.members.some( + (member, idx) => + member?.wallet?.toLowerCase() == currentChat?.groupInformation?.groupCreator?.toLowerCase() && + currentChat?.groupInformation?.members.unshift( + currentChat?.groupInformation?.members.splice(idx, 1)[0] + ) + ); + currentChat?.groupInformation?.members.some( + (member, idx) => + member?.wallet?.toLowerCase() == connectedUser.wallets?.toLowerCase() && + currentChat?.groupInformation?.members.unshift( + currentChat?.groupInformation?.members.splice(idx, 1)[0] + ) + ); + return currentChat; + } + return; + } export const MemberAlreadyPresent = (member:any,groupMembers:any)=>{ diff --git a/src/helpers/w2w/user.ts b/src/helpers/w2w/user.ts index 1eeedcac8a..fc6a12eb96 100644 --- a/src/helpers/w2w/user.ts +++ b/src/helpers/w2w/user.ts @@ -5,6 +5,7 @@ import { ConnectedUser, Feeds, IGroup, MessageIPFS, User } from 'types/chat'; import { walletToCAIP10 } from '.'; import { appConfig } from '../../config'; import { decrypt, message } from 'openpgp'; +import { getGroup } from 'services/chats/getGroup'; export function checkConnectedUser(connectedUser: ConnectedUser): boolean { if ( @@ -35,14 +36,14 @@ export const checkIfChatExist = ({ isGroup, }: CheckIfChatsExistPropType): boolean => { let val: boolean; - if (isGroup ) { - val = chats?.find((x) => x?.groupInformation?.chatId === currentChat?.groupInformation?.chatId) - ? true - : false; + if (isGroup) { + val = chats?.find((x) => x?.groupInformation?.chatId === currentChat?.groupInformation?.chatId) ? true : false; } else { // if(currentChat && currentChat?.combinedDID) val = chats?.find( - (x) => x?.combinedDID?.toLowerCase() === currentChat?.combinedDID?.toLowerCase() && x?.msg?.toDID?.toLowerCase() === connectedUser?.did?.toLowerCase() + (x) => + x?.combinedDID?.toLowerCase() === currentChat?.combinedDID?.toLowerCase() && + x?.msg?.toDID?.toLowerCase() === connectedUser?.did?.toLowerCase() ) ? true : false; @@ -70,7 +71,8 @@ export const getLatestThreadHash = ({ } else { latestThreadHash = inbox?.find((x) => x?.combinedDID?.toLowerCase() === currentChat?.combinedDID?.toLowerCase())?.threadhash || - receivedIntents?.find((x) => x?.combinedDID?.toLowerCase() === currentChat?.combinedDID?.toLowerCase())?.threadhash; + receivedIntents?.find((x) => x?.combinedDID?.toLowerCase() === currentChat?.combinedDID?.toLowerCase()) + ?.threadhash; } return latestThreadHash; @@ -106,25 +108,23 @@ export const getDefaultFeed = async ({ inbox: Feeds[]; intents: Feeds[]; }): Promise => { - const user = userData ?? (await PushAPI.user.get({ account: walletAddress!, env: appConfig.appEnv, })); - let feed:Feeds; - const inboxUser = inbox.filter((inb) => inb.did?.toLowerCase() === user.did?.toLowerCase()); - - const intentUser = intents.filter((userExist) => userExist.did?.toLowerCase() === user.did?.toLowerCase()); - if (inboxUser.length) { - feed = inboxUser[0]; - } else if(intentUser.length){ - feed = intentUser[0]; - } - else { - feed = getDefaultFeedObject({user}); -} + let feed: Feeds; + const inboxUser = inbox.filter((inb) => inb.did?.toLowerCase() === user.did?.toLowerCase()); + + const intentUser = intents.filter((userExist) => userExist.did?.toLowerCase() === user.did?.toLowerCase()); + if (inboxUser.length) { + feed = inboxUser[0]; + } else if (intentUser.length) { + feed = intentUser[0]; + } else { + feed = getDefaultFeedObject({ user }); + } return feed; }; @@ -136,25 +136,24 @@ export const getDefaultGroupFeed = async ({ groupData: IGroup; inbox: Feeds[]; intents: Feeds[]; -}): Promise<{feed:Feeds,isNew:boolean}> => { - let isNew:boolean = false; - let feed:Feeds; - const inboxGroup = inbox.filter((inb) => inb?.groupInformation?.chatId === groupData.chatId); - - const intentGroup = intents.filter((int) =>int?.groupInformation?.chatId === groupData.chatId); - if (inboxGroup.length) { - feed = inboxGroup[0]; - } else if(intentGroup.length){ - feed = intentGroup[0]; - } - else { - feed = getDefaultFeedObject({groupInformation:groupData}); - isNew = true; - } - return {feed,isNew}; +}): Promise<{ feed: Feeds; isNew: boolean }> => { + let isNew: boolean = false; + let feed: Feeds; + const inboxGroup = inbox.filter((inb) => inb?.groupInformation?.chatId === groupData.chatId); + + const intentGroup = intents.filter((int) => int?.groupInformation?.chatId === groupData.chatId); + if (inboxGroup.length) { + feed = inboxGroup[0]; + } else if (intentGroup.length) { + feed = intentGroup[0]; + } else { + feed = getDefaultFeedObject({ groupInformation: groupData }); + isNew = true; + } + return { feed, isNew }; }; -export const getDefaultFeedObject = ({user,groupInformation}:{user?:User,groupInformation?:IGroup}) => { +export const getDefaultFeedObject = ({ user, groupInformation }: { user?: User; groupInformation?: IGroup }) => { const feed = { msg: { messageContent: null, @@ -170,86 +169,120 @@ export const getDefaultFeedObject = ({user,groupInformation}:{user?:User,groupIn toDID: null, toCAIP10: null, }, - wallets: groupInformation?null: user.wallets, - did: groupInformation?null: user.did, + wallets: groupInformation ? null : user.wallets, + did: groupInformation ? null : user.did, threadhash: null, - profilePicture: groupInformation?groupInformation.groupImage:user.profilePicture, - about: groupInformation?null:user.about, + profilePicture: groupInformation ? groupInformation.groupImage : user.profilePicture, + about: groupInformation ? null : user.about, intent: null, intentSentBy: null, intentTimestamp: null, - publicKey: groupInformation?null: user.publicKey, + publicKey: groupInformation ? null : user.publicKey, combinedDID: null, cid: null, - groupInformation: groupInformation??undefined, + groupInformation: groupInformation ?? undefined, }; return feed; -} - - +}; -export const fetchInbox = async ({connectedUser, page, limit}:{connectedUser:any, page?:number, limit?:number}):Promise=> { - let inboxes:Feeds[] = await PushAPI.chat.chats({ account: connectedUser.wallets!, env: appConfig.appEnv, toDecrypt: true, pgpPrivateKey: connectedUser.privateKey, page, limit}); - return inboxes +export const fetchInbox = async ({ + connectedUser, + page, + limit, +}: { + connectedUser: any; + page?: number; + limit?: number; +}): Promise => { + let inboxes: Feeds[] = await PushAPI.chat.chats({ + account: connectedUser.wallets!, + env: appConfig.appEnv, + toDecrypt: true, + pgpPrivateKey: connectedUser.privateKey, + page, + limit, + }); + return inboxes; }; -export const fetchIntent = async ({connectedUser, page, limit}:{connectedUser:any, page?:number, limit?:number}): Promise => { - let intents = await PushAPI.chat.requests({account:connectedUser.wallets.split(':')[1], env:appConfig.appEnv, toDecrypt: true, pgpPrivateKey: connectedUser.privateKey, page, limit}); +export const fetchIntent = async ({ + connectedUser, + page, + limit, +}: { + connectedUser: any; + page?: number; + limit?: number; +}): Promise => { + let intents = await PushAPI.chat.requests({ + account: connectedUser.wallets.split(':')[1], + env: appConfig.appEnv, + toDecrypt: true, + pgpPrivateKey: connectedUser.privateKey, + page, + limit, + }); return intents; }; -export const getUpdatedChatAndIntent= async ({chatList,message,connectedUser,account, checkInbox})=>{ +export const getUpdatedChatAndIntent = async ({ chatList, message, connectedUser, account, checkInbox }) => { let isUpdated = false; - let decryptedChat:MessageIPFS; + let decryptedChat: MessageIPFS; //change to common decryption for getUpdatedInbox and getUpdatedChats using filter - const updatedFeed = chatList.filter(feed=>(feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase()) || (feed?.groupInformation?.chatId === message.toCAIP10)); - if(updatedFeed.length && checkInbox){ + const updatedFeed = chatList.filter( + (feed) => + feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase() || + feed?.groupInformation?.chatId === message.toCAIP10 + ); + if (updatedFeed.length && checkInbox) { decryptedChat = await w2wHelper.decryptMessages({ savedMsg: message, connectedUser, account, - currentChat:updatedFeed[0], - inbox:chatList + currentChat: updatedFeed[0], + inbox: chatList, }); + } else { + decryptedChat = updatedFeed[0]; } - else{ - decryptedChat=updatedFeed[0] - } - const updatedChatList = chatList.map(feed => { - if((feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase()) || feed?.groupInformation?.chatId === message.toCAIP10){ + const updatedChatList = chatList.map((feed) => { + if ( + feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase() || + feed?.groupInformation?.chatId === message.toCAIP10 + ) { feed.msg = decryptedChat; - isUpdated=true; + isUpdated = true; } return feed; }); - return checkInbox - ? {updatedInbox:updatedChatList, isInboxUpdated:isUpdated} - : {updatedIntents:updatedChatList, isIntentsUpdated:isUpdated}; -} + return checkInbox + ? { updatedInbox: updatedChatList, isInboxUpdated: isUpdated } + : { updatedIntents: updatedChatList, isIntentsUpdated: isUpdated }; +}; -export const getUpdatedGroupInfo = async({chatList, groupInfo, checkInbox})=>{ +export const getUpdatedGroupInfo = async ({ chatList, groupInfo, checkInbox }) => { let isUpdated = false; - const updatedChatList = chatList.map(feed => { - if(feed?.groupInformation?.chatId === groupInfo.chatId){ - feed.groupInformation = groupInfo; - isUpdated=true; + const updatedChatList = chatList.map((feed) => { + if (feed?.groupInformation?.chatId === groupInfo.chatId) { + (async () => { + const group = await getGroup(feed?.groupInformation?.chatId, () => {}); + if (group || !!Object.keys(group || {}).length) feed.groupInformation = group; + isUpdated = true; + })(); } return feed; }); - return checkInbox - ?{updatedInbox:updatedChatList, isInboxUpdated:isUpdated} - :{updatedIntents:updatedChatList, isIntentsUpdated:isUpdated} -} + return checkInbox + ? { updatedInbox: updatedChatList, isInboxUpdated: isUpdated } + : { updatedIntents: updatedChatList, isIntentsUpdated: isUpdated }; +}; -export const checkIfIntent = ({chat,account}):boolean => { - if(chat && (chat?.combinedDID?.toLowerCase())?.includes(walletToCAIP10({account})?.toLowerCase())) - { - if( chat?.intent && (chat?.intent?.toLowerCase())?.includes(walletToCAIP10({account})?.toLowerCase())) - return false; - else - return true; +export const checkIfIntent = ({ chat, account }): boolean => { + if (chat && chat?.combinedDID?.toLowerCase()?.includes(walletToCAIP10({ account })?.toLowerCase())) { + if (chat?.intent && chat?.intent?.toLowerCase()?.includes(walletToCAIP10({ account })?.toLowerCase())) return false; + else return true; } return false; -} \ No newline at end of file +}; diff --git a/src/modules/chat/ChatModule.tsx b/src/modules/chat/ChatModule.tsx index 2900ed2cad..7021166095 100644 --- a/src/modules/chat/ChatModule.tsx +++ b/src/modules/chat/ChatModule.tsx @@ -43,7 +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'; +import { ChatUIProvider, IGroup } from '@pushprotocol/uiweb'; export const ToastPosition: ToastOptions = { position: 'top-right', @@ -68,7 +68,6 @@ function Chat({ chatid }) { const [viewChatBox, setViewChatBox] = useState(false); const [currentChat, setCurrentChat] = useState(); - const [messages, setMessages] = useState([]); const [receivedIntents, setReceivedIntents] = useState([]); const [isLoading, setIsLoading] = useState(true); const [loadingMessage, setLoadingMessage] = useState(''); @@ -90,7 +89,6 @@ function Chat({ chatid }) { useEffect(()=>{ if(connectedUser && socketData.messagesSinceLastConnection && ((w2wHelper.caip10ToWallet(socketData.messagesSinceLastConnection.fromCAIP10)).toLowerCase() !== account.toLowerCase())){ if(currentChat) - getUpdatedChats(socketData.messagesSinceLastConnection); getUpdatedInbox(socketData.messagesSinceLastConnection) } },[socketData.messagesSinceLastConnection]) @@ -101,30 +99,17 @@ function Chat({ chatid }) { } },[socketData.groupInformationSinceLastConnection]) - const getUpdatedChats = async(chat) => { - if((currentChat.did?.toLowerCase() === chat.fromCAIP10?.toLowerCase()) || currentChat?.groupInformation?.chatId === chat.toCAIP10){ - const decryptedChat:MessageIPFS = await w2wHelper.decryptMessages({ - savedMsg: chat, - connectedUser, - account, - currentChat, - inbox - }); - setMessages([...messages,{...decryptedChat,cid:socketData.messagesSinceLastConnection.cid}]); - } - } + const getUpdatedInbox = async(message) => { let isListUpdated=false; const {updatedInbox,isInboxUpdated}=await getUpdatedChatAndIntent({chatList:inbox,message,connectedUser,account,checkInbox:true}); - // console.log("feed isChatList updated?",isInboxUpdated) if(isInboxUpdated){ isListUpdated=true; setInbox(updatedInbox); } else{ const {updatedIntents,isIntentsUpdated}=await getUpdatedChatAndIntent({chatList:receivedIntents,message,connectedUser,account,checkInbox:false}); - // console.log("intent isChatList updated?",isIntentsUpdated) if(isIntentsUpdated){ isListUpdated=true; setReceivedIntents(updatedIntents); @@ -139,7 +124,7 @@ function Chat({ chatid }) { env: appConfig.appEnv }); if(checkIfIntent({chat:fetchedChat, account})){ - setReceivedIntents(prev=> [fetchedChat, ...prev]); + setReceivedIntents(prev=> [fetchedChat , ...prev]); } else{ @@ -147,36 +132,7 @@ function Chat({ chatid }) { } } - // let isInInbox = false; - // let decryptedChat:MessageIPFS; - - // //change to common decryption for getUpdatedInbox and getUpdatedChats using filter - // const updatedFeed = inbox.filter(feed=>(feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase()) || (feed?.groupInformation?.chatId === message.toCAIP10)); - // if(updatedFeed.length){ - // decryptedChat = await w2wHelper.decryptMessages({ - // savedMsg: message, - // connectedUser, - // account, - // currentChat:updatedFeed[0], - // inbox - // }); - // } - // const updatedInbox = inbox.map(feed => { - // if((feed.did?.toLowerCase() === message.fromCAIP10?.toLowerCase()) || feed?.groupInformation?.chatId === message.toCAIP10){ - // feed.msg = decryptedChat; - // isInInbox = true; - // } - // return feed; - // }); - // if(isInInbox){ - - // setInbox(updatedInbox); - // } - // else if(!isInInbox){ - // //update msg for already received intents - // const intents = await fetchIntent({connectedUser}); - // setReceivedIntents(intents); - // } + } const getUpdatedGroup = async(groupInfo) => { @@ -208,21 +164,7 @@ const getUpdatedGroup = async(groupInfo) => { setInbox(prev=>[fetchedChat,...prev]) } } - // let isInInbox = false; - // const updatedInbox = inbox.map(feed => { - // if(feed?.groupInformation?.chatId === groupInfo.chatId){ - // feed.groupInformation = groupInfo; - // isInInbox = true; - // } - // return feed; - // }); - // if(isInInbox){ - // setInbox(updatedInbox); - // } - // else { - // const intents = await fetchIntent({connectedUser}); - // setReceivedIntents(intents); - // } + } // React GA Analytics @@ -283,7 +225,6 @@ const getUpdatedGroup = async(groupInfo) => { 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(); @@ -398,7 +339,6 @@ const getUpdatedGroup = async(groupInfo) => { }; useEffect(() => { - console.log(account, connectedUser?.privateKey, "kkkk") }, [account, connectedUser?.privateKey]) return ( @@ -415,8 +355,6 @@ const getUpdatedGroup = async(groupInfo) => { viewChatBox, setChat, intents, - messages, - setMessages, setIntents, inbox, setInbox, diff --git a/src/modules/createChannel/CreateChannelModule.js b/src/modules/createChannel/CreateChannelModule.js index f2f3f815f7..21644563b7 100644 --- a/src/modules/createChannel/CreateChannelModule.js +++ b/src/modules/createChannel/CreateChannelModule.js @@ -334,7 +334,7 @@ function CreateChannelModule() { } const tx = await contract.createChannelWithPUSH(channelType, identityBytes, fees, timestampIfTimebound, { - gasLimit: 1000000, + gasLimit: 600000, }); console.log(tx); diff --git a/src/modules/receiveNotifs/MetamaskPushSnapModal.tsx b/src/modules/receiveNotifs/MetamaskPushSnapModal.tsx index 351d77d3af..2bfb7fdef9 100644 --- a/src/modules/receiveNotifs/MetamaskPushSnapModal.tsx +++ b/src/modules/receiveNotifs/MetamaskPushSnapModal.tsx @@ -17,7 +17,11 @@ import GLOBALS, { device, globalsMargin } from "config/Globals"; import { useLocation } from 'react-router-dom'; const MetamaskPushSnapModal = ({ - onClose + onClose, + closeEnabled = true +}: { + onClose: () => void, + closeEnabled?: boolean }) => { const theme = useTheme(); const location = useLocation(); @@ -54,10 +58,12 @@ const MetamaskPushSnapModal = ({ > Receive Notifications } - + {closeEnabled && + + } {SnapState == 1 && } diff --git a/src/modules/receiveNotifs/ReceiveNotifsModule.tsx b/src/modules/receiveNotifs/ReceiveNotifsModule.tsx index a4aaf38d00..0a51ca8d46 100644 --- a/src/modules/receiveNotifs/ReceiveNotifsModule.tsx +++ b/src/modules/receiveNotifs/ReceiveNotifsModule.tsx @@ -22,58 +22,11 @@ function ReceiveNotifsModule() { // get theme const theme = useTheme(); - //notification modal - // const { - // isModalOpen: isMetamaskPushSnapOpen, - // showModal: showMetamaskPushSnap, - // ModalComponent: MetamaskPushSnapModalComponent, - // } = useModalBlur(); - - // React.useEffect(()=>{ - // showMetamaskPushSnap(); - // },[]) - - // React.useEffect(()=>{ - // showMetamaskPushSnap(); - // },[]) - // Render return ( - - {/* */} - - - - -

- - Receive Notifications - -

- - The following frontends enables receiving push alerts for your wallet. More coming soon! - -
- - - - - + {}} closeEnabled={false} />
); @@ -91,7 +44,7 @@ const Container = styled(Section)` flex: initial; justify-content: center; max-width: 1200px; - width: calc(100% - ${globalsMargin.MINI_MODULES.DESKTOP.RIGHT} - ${globalsMargin.MINI_MODULES.DESKTOP.LEFT} - ${GLOBALS.ADJUSTMENTS.PADDING.BIG} - ${GLOBALS.ADJUSTMENTS.PADDING.BIG}); + width: auto; padding: ${GLOBALS.ADJUSTMENTS.PADDING.BIG}; position: relative; margin: ${GLOBALS.ADJUSTMENTS.MARGIN.MINI_MODULES.DESKTOP}; @@ -99,13 +52,11 @@ const Container = styled(Section)` @media ${device.laptop} { margin: ${GLOBALS.ADJUSTMENTS.MARGIN.MINI_MODULES.TABLET}; padding: ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT}; - width: calc(100% - ${globalsMargin.MINI_MODULES.TABLET.RIGHT} - ${globalsMargin.MINI_MODULES.TABLET.LEFT} - ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT} - ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT}); } @media ${device.mobileL} { margin: ${GLOBALS.ADJUSTMENTS.MARGIN.MINI_MODULES.MOBILE}; padding: ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT}; - width: calc(100% - ${globalsMargin.MINI_MODULES.MOBILE.RIGHT} - ${globalsMargin.MINI_MODULES.MOBILE.LEFT} - ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT} - ${GLOBALS.ADJUSTMENTS.PADDING.DEFAULT}); } `; diff --git a/src/sections/chat/ChatBoxSection.tsx b/src/sections/chat/ChatBoxSection.tsx index 5ad002c3a6..e7be235b8b 100644 --- a/src/sections/chat/ChatBoxSection.tsx +++ b/src/sections/chat/ChatBoxSection.tsx @@ -15,7 +15,7 @@ import GLOBALS from 'config/Globals'; const ChatBoxSection = ({ showGroupInfoModal }) => { // RENDER return ( - + diff --git a/src/types/chat.ts b/src/types/chat.ts index 201074f3a9..6f2875b6e7 100644 --- a/src/types/chat.ts +++ b/src/types/chat.ts @@ -126,8 +126,6 @@ export interface AppContext { setLoadingMessage: (loadingMessage: string) => void; setBlockedLoading: (blockedLoading: BlockedLoadingI) => void; activeTab: number; - messages:MessageIPFSWithCID[], - setMessages:(msg:MessageIPFSWithCID[])=>void; setActiveTab: (active: number) => void; userShouldBeSearched: boolean; setUserShouldBeSearched: (value: boolean) => void; diff --git a/yarn.lock b/yarn.lock index d7b375f072..67a915caa6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4476,15 +4476,6 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/iframe-provider@npm:^0.4.2": - version: 0.4.3 - resolution: "@ledgerhq/iframe-provider@npm:0.4.3" - dependencies: - eventemitter3: ^4.0.0 - checksum: 7dd6cd241c532993c9d37e788ce8b756580d277624fffec220372d6693366527206743985b14e66fe14bc1d843dbf17ef084ea4725501fa408e91bed66ff80f2 - languageName: node - linkType: hard - "@leichtgewicht/ip-codec@npm:^2.0.1": version: 2.0.4 resolution: "@leichtgewicht/ip-codec@npm:2.0.4" @@ -5441,10 +5432,9 @@ __metadata: "@mui/icons-material": ^5.8.4 "@mui/lab": ^5.0.0-alpha.72 "@mui/material": ^5.5.0 - "@pushprotocol/ledgerlive": latest - "@pushprotocol/restapi": 1.4.41 + "@pushprotocol/restapi": 1.4.45 "@pushprotocol/socket": 0.5.3 - "@pushprotocol/uiweb": 1.1.19 + "@pushprotocol/uiweb": 1.1.23 "@reduxjs/toolkit": ^1.7.1 "@testing-library/dom": ^6.12.2 "@testing-library/jest-dom": ^4.2.4 @@ -5631,21 +5621,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/ledgerlive@npm:latest": - version: 0.0.1 - resolution: "@pushprotocol/ledgerlive@npm:0.0.1" - dependencies: - "@ledgerhq/iframe-provider": ^0.4.2 - "@web3-react/abstract-connector": ^6.0.7 - tiny-invariant: ^1.2.0 - tslib: ^2.3.0 - checksum: 3600e1e8faedec80a3f76d3f224d3cf2ac5daf1e80a270a80ad73187cae2e00251e33f019b9675515250ffa2eef0231a3b76b83cebb6b87af00299e59961e581 - languageName: node - linkType: hard - -"@pushprotocol/restapi@npm:1.4.41": - version: 1.4.41 - resolution: "@pushprotocol/restapi@npm:1.4.41" +"@pushprotocol/restapi@npm:1.4.45": + version: 1.4.45 + resolution: "@pushprotocol/restapi@npm:1.4.45" dependencies: "@ambire/signature-validator": ^1.3.1 "@metamask/eth-sig-util": ^5.0.2 @@ -5666,7 +5644,7 @@ __metadata: viem: ^1.3.0 peerDependencies: ethers: ^5.6.8 - checksum: bdf64d7d7d89d820f6bfb292c5ec3c8bf999d03dd560e4497977e910deed72ee3ea29c72c9193b37034b990fb2d901b75246829313368aa0c3634faec317802b + checksum: 08324581fdad86fca1dc6e947263468ed010f0d1ca95d58ffeee97b4d00e64e31dec182c5cde8c3f2c3fbddec6e64e2178c2bf6b6d675919de1d51a449757216 languageName: node linkType: hard @@ -5706,9 +5684,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:1.1.19": - version: 1.1.19 - resolution: "@pushprotocol/uiweb@npm:1.1.19" +"@pushprotocol/uiweb@npm:1.1.23": + version: 1.1.23 + resolution: "@pushprotocol/uiweb@npm:1.1.23" dependencies: "@livekit/components-react": ^1.2.2 "@livekit/components-styles": ^1.0.6 @@ -5740,7 +5718,7 @@ __metadata: axios: ^0.27.2 react: ">=16.8.0" styled-components: ^6.0.8 - checksum: 1180e8a37039825f5bfd518b1e7675b3bc2a95b7a511cddb22d0390cf742cfb7589dc28b59fc82bfc8f43ed1da9324374653275d0a5f88452b8b2fa83dd607df + checksum: 7113c048b5185643c3d6f6f44aedc74023496daf4beafad2379e6d48aa6295c5c939b15ba9b81a17f765cbafc49648688e63d668a1416b6ec593763f7ff68bd7 languageName: node linkType: hard