diff --git a/package.json b/package.json index c206c8ba5c..ec08fc8902 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "@metamask/eth-sig-util": "^4.0.0", "@mui/icons-material": "^5.8.4", "@mui/material": "^5.5.0", - "@pushprotocol/restapi": "1.7.25", + "@pushprotocol/restapi": "1.7.29", "@pushprotocol/socket": "0.5.3", - "@pushprotocol/uiweb": "1.7.1", + "@pushprotocol/uiweb": "1.7.2", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-switch": "^1.1.0", diff --git a/src/blocks/icons/components/Asterisk.tsx b/src/blocks/icons/components/Asterisk.tsx index 6313a21f20..05ca467a07 100644 --- a/src/blocks/icons/components/Asterisk.tsx +++ b/src/blocks/icons/components/Asterisk.tsx @@ -9,16 +9,33 @@ const Asterisk: FC = (allProps) => { componentName="Asterisk" icon={ + + } diff --git a/src/blocks/icons/components/FillCircle.tsx b/src/blocks/icons/components/FillCircle.tsx new file mode 100644 index 0000000000..271e50b978 --- /dev/null +++ b/src/blocks/icons/components/FillCircle.tsx @@ -0,0 +1,32 @@ +import { FC } from 'react'; +import { IconWrapper } from '../IconWrapper'; +import { IconProps } from '../Icons.types'; + +const FillCircle: FC = (allProps) => { + const { svgProps: props, ...restProps } = allProps; + return ( + + + + } + {...restProps} + /> + ); +}; + +export default FillCircle; diff --git a/src/blocks/icons/components/Image.tsx b/src/blocks/icons/components/Image.tsx new file mode 100644 index 0000000000..b89b65265f --- /dev/null +++ b/src/blocks/icons/components/Image.tsx @@ -0,0 +1,55 @@ +import { FC } from 'react'; +import { IconWrapper } from '../IconWrapper'; +import { IconProps } from '../Icons.types'; + +const Image: FC = (allProps) => { + const { svgProps: props, ...restProps } = allProps; + return ( + + + + + + + } + {...restProps} + /> + ); +}; + +export default Image; diff --git a/src/blocks/icons/components/Lock.tsx b/src/blocks/icons/components/Lock.tsx index 9b95956f11..1937767e9a 100644 --- a/src/blocks/icons/components/Lock.tsx +++ b/src/blocks/icons/components/Lock.tsx @@ -12,23 +12,38 @@ const Lock: FC = (allProps) => { xmlns="http://www.w3.org/2000/svg" width="inherit" height="inherit" - viewBox="0 0 29 28" + viewBox="0 0 32 32" fill="none" {...props} > - + + + - + diff --git a/src/blocks/icons/components/Logout.tsx b/src/blocks/icons/components/Logout.tsx index b6d129e4b2..d923a5bdd2 100644 --- a/src/blocks/icons/components/Logout.tsx +++ b/src/blocks/icons/components/Logout.tsx @@ -12,24 +12,24 @@ const Logout: FC = (allProps) => { xmlns="http://www.w3.org/2000/svg" width="inherit" height="inherit" - viewBox="0 0 24 24" + viewBox="0 0 32 32" fill="none" {...props} > = []; // Export the notification object with show and hide methods const notification = { - show: (config: NotificationProps) => { + show: (config: NotificationProps, id?: string) => { const toastId = toast.custom(() => , { + id: id, duration: config.duration || Infinity, position: config.position || 'bottom-right', + onAutoClose: config.onAutoClose, }); - toastIds.push(toastId); + if (!toastIds.find((toastId) => toastId === id)) toastIds.push(toastId); }, hide: () => { if (toastIds.length > 0) { diff --git a/src/blocks/notification/Notification.types.ts b/src/blocks/notification/Notification.types.ts index 924f78109a..313bd31f02 100644 --- a/src/blocks/notification/Notification.types.ts +++ b/src/blocks/notification/Notification.types.ts @@ -16,4 +16,6 @@ export type NotificationProps = { position?: 'bottom-right' | 'bottom-left' | 'top-center'; /* Optional duration of the notification component */ duration?: number; + /* Optional onAutoClose event for the notification called after it's timeout */ + onAutoClose?: () => void; }; diff --git a/src/blocks/text/Text.constants.ts b/src/blocks/text/Text.constants.ts index 9eaa1275f2..0fd673960e 100644 --- a/src/blocks/text/Text.constants.ts +++ b/src/blocks/text/Text.constants.ts @@ -352,11 +352,19 @@ export const textVariants = { letterSpacing: null, textTransform: 'uppercase', }, + 'c-regular': { + fontSize: '12px', + fontStyle: null, + fontWeight: '400', + lineHeight: '16px', + letterSpacing: null, + textTransform: null, + }, 'c-semibold': { - fontSize: '10px', + fontSize: '12px', fontStyle: null, fontWeight: 500, - lineHeight: '14px', + lineHeight: '16px', letterSpacing: null, textTransform: null, }, @@ -368,11 +376,27 @@ export const textVariants = { letterSpacing: null, textTransform: null, }, - 'c-regular': { - fontSize: '12px', + 'cs-regular': { + fontSize: '10px', fontStyle: null, fontWeight: '400', - lineHeight: '16px', + lineHeight: '14px', + letterSpacing: null, + textTransform: null, + }, + 'cs-semibold': { + fontSize: '10px', + fontStyle: null, + fontWeight: 500, + lineHeight: '14px', + letterSpacing: null, + textTransform: null, + }, + 'cs-bold': { + fontSize: '12px', + fontStyle: null, + fontWeight: '700', + lineHeight: '14px', letterSpacing: null, textTransform: null, }, diff --git a/src/common/Common.baseLogos.ts b/src/common/Common.baseLogos.ts index 4c13172e6f..8b28675a07 100644 --- a/src/common/Common.baseLogos.ts +++ b/src/common/Common.baseLogos.ts @@ -18,3 +18,6 @@ export const pwnLogo = export const udLogo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAFVpJREFUeF7tnXuQXFWdxz/n3tuP6cfkMeQxGKIJyCM8IiZAgDxMIIEl8rCyCKvWrlhFsSr4ABFYFEgABdRoqSwr5WsXV1eLUqwSQRcFXKKJW6wQJIFACJgnk2Qy0+/b97V1bndPOsnMdPf0vT09k3v/mJqqPvdxfr/v+Z7f+Z3f73dE8jrbIbiOWgmIAABHre7djgcAOLr1HwDgKNd/AIAAAIEReFRjILABjmr1B0bgUa7+AABtAwDTFjgOhFWHVjpmgilglCEglZ3JC7AsujotinaopV8UAKCl4j70ZdmiwM7C8TN01q7qYf1WwX2/nUE85iCERx9mu+4eUAbnlQAAHsm5kccUDIGRhYmdOp+7sJfb/z4KiuCLP85zz6+6SSS9AYAwBY5t4XQUEFZs0E8MANCI5ppsa1iCQha0sMm1C3q4+4MqXZMjpRGKw62P5Ln/yW4SieYBIAoCWy1SuNhB3ZEm8uJknOiRtBIAoEml1nO75QhyWaljk1Xz09x7RZ6TZnUACrgULf/1CACOQGQdrCl5CpeEsE8I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DBJ7v/xNYwKDcEio0B9AbADQeud5cEgLWB4qoJQAEwFutsAfSWdnn72iVAXEA5ACrl56rpqbJbmoqrAsDlAy+BdLImKepXyUwCztYBBcBY7gL0U2EJtaw89ChbAJjGLREA985aN3ghRwnhYOuyZQsANxSwu3cp6v8BKy56+Q/sj5UAAAAASUVORK5CYII='; diff --git a/src/common/Common.utils.tsx b/src/common/Common.utils.tsx index ea6c7b8c83..7b33acc08f 100644 --- a/src/common/Common.utils.tsx +++ b/src/common/Common.utils.tsx @@ -2,6 +2,7 @@ import { appConfig } from 'config'; import { LOGO_ALIAS_CHAIN } from './Common.constants'; import { networkName } from 'helpers/UtilityHelper'; import { EnvType } from './Common.types'; +import moment from 'moment'; export const allowedNetworks = appConfig.allowedNetworks.filter( (chain: number) => chain != appConfig.coreContractChain @@ -53,3 +54,19 @@ export const isValidURL = (str: string | undefined) => { export const getCurrentEnv = (): EnvType => { return appConfig.appEnv; }; + +export function convertTimeStamp(timestamp: string) { + const date = moment.unix(Number(timestamp)); + const now = moment(); + + const diffInSeconds = now.diff(date, 'seconds'); + const diffInMinutes = now.diff(date, 'minutes'); + + if (diffInSeconds < 60) { + return 'now'; + } else if (diffInMinutes < 60) { + return `${diffInMinutes} minutes ago`; + } else { + return date.format('hh:mm A'); + } +} diff --git a/src/common/components/InAppChatNotifications.tsx b/src/common/components/InAppChatNotifications.tsx new file mode 100644 index 0000000000..e4e33aa84d --- /dev/null +++ b/src/common/components/InAppChatNotifications.tsx @@ -0,0 +1,222 @@ +import { FC, useContext } from 'react'; + +import { useNavigate } from 'react-router-dom'; +import { css } from 'styled-components'; + +import { Box, Cross, Pin, Text, Image, FillCircle, ChatFilled, EditProfile } from 'blocks'; + +import { AppContextType } from 'types/context'; +import { AppContext } from 'contexts/AppContext'; + +import { convertTimeStamp } from 'common/Common.utils'; +import { shortenText } from 'helpers/UtilityHelper'; +import { caip10ToWallet } from 'helpers/w2w'; + +import { useResolveWeb3Name } from 'hooks/useResolveWeb3Name'; +import { useGetGroupInfo, useGetUserProfileDetails } from 'queries'; + +type InAppChatNotificationsProps = { + chatDetails: Array; + onClose: () => void; +}; + +const getContentText = (chatDetail: any) => { + if (chatDetail.message.type === 'Text') return chatDetail.message.content; + if (chatDetail.message.type === 'Image') return 'Image'; + if (chatDetail.message.type === 'File') return 'File'; + if (chatDetail.message.type === 'MediaEmbed' || chatDetail.message.type === 'GIF') return 'GIF'; +}; +const getContentImage = (chatDetail: any) => { + if ( + chatDetail.message.type === 'Image' || + chatDetail.message.type === 'MediaEmbed' || + chatDetail.message.type === 'GIF' + ) + return ( + + ); + if (chatDetail.message.type === 'File') + return ( + + ); +}; + +const InAppChatNotifications: FC = ({ chatDetails, onClose }) => { + const { web3NameList }: AppContextType = useContext(AppContext)!; + const fromAddress = caip10ToWallet(chatDetails[0]?.from); + const { data: userProfileDetails } = useGetUserProfileDetails(fromAddress, { + refetchOnWindowFocus: false, + staleTime: Infinity, + refetchInterval: 3600000, // 1 hour, + }); + const { data: groupInfo } = useGetGroupInfo(chatDetails[0]?.meta?.group ? chatDetails[0].chatId : '', { + refetchOnWindowFocus: false, + staleTime: Infinity, + refetchInterval: 3600000, // 1 hour, + }); + + const navigate = useNavigate(); + + useResolveWeb3Name(fromAddress); + const web3Name = web3NameList[fromAddress]; + const sender = web3Name ? web3Name : shortenText(fromAddress, 6); + const displayName = chatDetails[0]?.meta?.group + ? groupInfo?.groupName || shortenText(chatDetails[0]?.chatId, 6) + : web3Name || shortenText(fromAddress, 6); + + const latestTimestamp = convertTimeStamp(chatDetails[chatDetails.length - 1]?.timestamp); + + //optimise it and fix the close button z-index + return ( + + {chatDetails && userProfileDetails && ( + navigate(`/chat/chatid:${chatDetails[0].chatId}`)} + > + + + + {chatDetails[0].event === 'chat.request' ? ( + + ) : ( + {displayName} + )} + + + {chatDetails[0].event === 'chat.request' ? 'Push Chat' : displayName} + + + + {latestTimestamp} + + + { + e.stopPropagation(); + onClose(); + }} + cursor="pointer" + > + + + + {chatDetails.map((chatDetail: any) => + chatDetail.event === 'chat.request' ? ( + + + + + {displayName}{' '} + + + has sent you a chat request + + + + ) : ( + + + {chatDetails[0]?.meta?.group && ( + + {sender}{' '} + + )} + {chatDetail.message.type !== 'Text' ? {getContentImage(chatDetail)} : null} + + {getContentText(chatDetail)} + + + + ) + )} + + )} + + ); +}; + +export { InAppChatNotifications }; diff --git a/src/common/components/index.ts b/src/common/components/index.ts index 465df82dad..4b5412cac5 100644 --- a/src/common/components/index.ts +++ b/src/common/components/index.ts @@ -9,3 +9,4 @@ export * from './TokenFaucet'; export * from './CopyButton'; export * from './VerifiedChannelTooltipContent'; export * from './InAppChannelNotifications'; +export * from './InAppChatNotifications'; diff --git a/src/common/hooks/useInAppNotifications.tsx b/src/common/hooks/useInAppNotifications.tsx index 592b596648..2f58a684ab 100644 --- a/src/common/hooks/useInAppNotifications.tsx +++ b/src/common/hooks/useInAppNotifications.tsx @@ -1,15 +1,16 @@ import { useEffect, useState } from 'react'; -import { CONSTANTS, NotificationEvent } from '@pushprotocol/restapi'; import { useSelector } from 'react-redux'; +import { CONSTANTS, NotificationEvent } from '@pushprotocol/restapi'; import { deviceSizes, notification } from 'blocks'; -import { InAppChannelNotifications } from 'common'; +import { InAppChannelNotifications, InAppChatNotifications } from 'common'; import { useDeviceWidthCheck } from 'hooks'; export const useInAppNotifications = () => { const [isStreamConnected, setIsStreamConnected] = useState(false); + const [newMessages, setNewMessages] = useState>>({}); const isMobile = useDeviceWidthCheck(parseInt(deviceSizes.mobileL)); const { userPushSDKInstance } = useSelector((state: any) => { return state.user; @@ -42,27 +43,87 @@ export const useInAppNotifications = () => { userPushSDKInstance?.stream?.uid, userPushSDKInstance?.stream ); - notification.show({ - overlay: , - position: isMobile ? 'top-center' : 'bottom-right', - duration: 5000, - onClick: () => { - notification.hide(); - }, - }); + if (data.source != 'PUSH_CHAT') + notification.show({ + overlay: , + position: isMobile ? 'top-center' : 'bottom-right', + duration: 5000, + onClick: () => { + notification.hide(); + }, + }); }); - }; + userPushSDKInstance?.stream?.on(CONSTANTS.STREAM.CHAT, (data: any) => { + console.debug( + 'src::common::hooks::useStream::attachListeners::CHAT::', + userPushSDKInstance?.uid, + userPushSDKInstance?.stream.connected(), + userPushSDKInstance?.stream?.uid, + userPushSDKInstance?.stream + ); - useEffect(() => { - (async () => { - if (userPushSDKInstance && userPushSDKInstance?.stream) { - await attachListeners(); + if ((data.event === 'chat.message' || data.event === 'chat.request') && data.origin === 'other') { + let updatedMessages: Record> = newMessages; + if (!updatedMessages[data.chatId]) { + updatedMessages[data.chatId] = []; + } + // Ensure the chat array length does not exceed 5 messages + if (updatedMessages[data.chatId].length > 5) { + updatedMessages[data.chatId] = updatedMessages[data.chatId].slice(-5); + } + if (!(updatedMessages[data.chatId].length && data.event === 'chat.request')) { + updatedMessages[data.chatId].push(data); + } + setNewMessages(updatedMessages); + notification.show( + { + overlay: ( + { + resetChatMessages(data.chatId); + notification.hide(); + }} + /> + ), + position: isMobile ? 'top-center' : 'bottom-right', + duration: 5000, + onAutoClose: () => resetChatMessages(data.chatId), + onClick: () => { + resetChatMessages(data.chatId); + notification.hide(); + }, + }, + data.chatId + ); } - })(); + }); + }; + + /* remove previous messages for a particular chat*/ + const resetChatMessages = (chatId: string) => { + const updatedMessages = newMessages; + delete updatedMessages[chatId]; + setNewMessages(updatedMessages); + }; - // Cleanup listener on unmount - return () => {}; - }, [userPushSDKInstance?.account]); + const streamAttach = () => { + if (userPushSDKInstance && userPushSDKInstance?.stream) { + attachListeners(); + } + }; + const streamCleanup = () => { + if (userPushSDKInstance && userPushSDKInstance?.stream) { + userPushSDKInstance?.stream?.disconnect(); + } + }; + + useEffect(() => { + streamAttach(); + return () => { + streamCleanup(); + }; + }, [userPushSDKInstance?.account, userPushSDKInstance?.readmode()]); return { isStreamConnected }; }; diff --git a/src/components/PushSnap/PushSnapSettings.tsx b/src/components/PushSnap/PushSnapSettings.tsx index e509132ac4..cda4ba6b07 100644 --- a/src/components/PushSnap/PushSnapSettings.tsx +++ b/src/components/PushSnap/PushSnapSettings.tsx @@ -10,14 +10,15 @@ import useModalBlur, { MODAL_POSITION } from 'hooks/useModalBlur'; import AboutSnapModal from 'modules/snap/AboutSnapModal'; import styled, { useTheme } from 'styled-components'; import PushSnapConfigureModal from './PushSnapConfigureModal'; -import { Alert, Box, Button, Text } from 'blocks'; +import { Alert, Box, Button, Metamask, Text } from 'blocks'; import { SnoozeDurationType } from 'types'; const PushSnapSettings = () => { - const { account, isWalletConnected, connect } = useAccount(); + const { account, isWalletConnected, connect, provider } = useAccount(); const theme = useTheme(); const [loading, setLoading] = useState(false); + const [walletConnected, setWalletConnected] = useState(false); const [addedAddress, setAddedAddress] = useState(false); const [errorMessage, setErrorMessage] = useState(null); @@ -31,11 +32,11 @@ const PushSnapSettings = () => { async function getInstalledSnaps() { if (!isWalletConnected) { - setErrorMessage("Connect your metamask wallet to install Snap"); + setErrorMessage('Connect your metamask wallet to install Snap'); setSnapInstalled(false); - return + return; } - setErrorMessage('') + setErrorMessage(''); const installedSnaps = await window.ethereum.request({ method: 'wallet_getSnaps', }); @@ -46,6 +47,39 @@ const PushSnapSettings = () => { } }); } + + async function getSignature(account: string) { + const signer = provider.getSigner(account); + const signature = await signer.signMessage(`Add address ${account} to receive notifications through Push Snap`); + return signature; + } + + async function addwalletAddress() { + try { + const signatureResult = await getSignature(account); + if (signatureResult) { + if (account) { + await window.ethereum?.request({ + method: 'wallet_invokeSnap', + params: { + snapId: defaultSnapOrigin, + request: { + method: 'pushproto_addaddress', + params: { address: account }, + }, + }, + }); + console.debug('Added', account); + setWalletConnected(true); + } + } else { + console.error('Signature Validation Failed'); + } + } catch (error: any) { + setErrorMessage(error.message); + } + } + async function getWalletAddresses() { const result = await window.ethereum?.request({ method: 'wallet_invokeSnap', @@ -55,10 +89,10 @@ const PushSnapSettings = () => { }, }); - console.debug(account); if (result.includes(account)) { setAddedAddress(true); + setWalletConnected(true); } else { setAddedAddress(false); } @@ -88,12 +122,15 @@ const PushSnapSettings = () => { setErrorMessage('Connect your metamask wallet to install Snap'); return; } - setErrorMessage('') + setErrorMessage(''); setLoading(true); try { if (!isWalletConnected) await connect(); if (!snapInstalled) { await connectSnap(); + getInstalledSnaps(); + } else { + await addwalletAddress(); } setLoading(false); } catch (error) { @@ -164,8 +201,13 @@ const PushSnapSettings = () => { /> )} - - {loading ? ( + + {/* {loading ? ( { ) : ( )} - + */} + {loading && !snapInstalled ? ( + + ) : ( + + )} + {loading && snapInstalled ? ( + + ) : ( + + )} + { return ( <> - {!snapInstalled ? ( + {!walletConnected ? ( ) : ( <> - Push Snap Settings + Push Snap Settings - )} @@ -224,7 +306,7 @@ export default PushSnapSettings; const Container = styled(Section)` width: 438px; - height: 423px; + height: auto; border-radius: 32px; background: #fff; background: ${(props) => props.theme.default.bg}; diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index 7ef381d0b3..1ecc055873 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -223,7 +223,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { // call initializePushSDK if decryptedPGPKeys is not null if (decryptedPGPKeys) { console.debug('src::contexts::AppContext::initializePushSdkReadMode::Called initializePushSDK()'); - return initializePushSDK(); + return initializePushSDK(wallet); } // else initialize push sdk in read mode @@ -288,10 +288,10 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { progress: 100, }); } - dispatch(setUserPushSDKInstance(userInstance)); // connect stream as well await setupStream(userInstance); + dispatch(setUserPushSDKInstance(userInstance)); return userInstance; } catch (error) { // Handle initialization error @@ -307,12 +307,11 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { CONSTANTS.STREAM.CONNECT, CONSTANTS.STREAM.DISCONNECT, CONSTANTS.STREAM.CHAT, - CONSTANTS.STREAM.CHAT_OPS, CONSTANTS.STREAM.NOTIF, CONSTANTS.STREAM.VIDEO, ]); - if (userInstance.readmode()) await stream.connect(); + await stream.connect(); console.debug('src::contexts::AppContext::setupStream::User Intance Stream Connected', userInstance); } }; @@ -489,7 +488,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => { } }; initialize(); - }, [account, provider]); + }, [account]); const createUserIfNecessary = async (): Promise => { try { diff --git a/src/modules/rewards/components/ActivityButton.tsx b/src/modules/rewards/components/ActivityButton.tsx index 684fa37e3d..482b392b1f 100644 --- a/src/modules/rewards/components/ActivityButton.tsx +++ b/src/modules/rewards/components/ActivityButton.tsx @@ -2,7 +2,7 @@ import { FC } from 'react'; //Queries -import { ActvityType, UsersActivity } from 'queries'; +import { ActvityType, useGetPushStakeEpoch, useGetUniV2StakeEpoch, UsersActivity } from 'queries'; import { Button } from 'blocks'; import { ActivityVerificationButton } from './ActivityVerificationButton'; import { useRewardsContext } from 'contexts/RewardsContext'; @@ -31,14 +31,39 @@ const ActivityButton: FC = ({ usersSingleActivity, isLoadingActivity, label, - isStakeSection, - lifeTime, }) => { const { resetEpoch } = useRewardsContext(); + const { data: pushStakeData } = useGetPushStakeEpoch(); + const { data: uniV2StakeData } = useGetUniV2StakeEpoch(); + const isPushEpochRelated = + typeof usersSingleActivity?.activityTypeId === 'string' && + usersSingleActivity.activityTypeId.endsWith('push_epoch'); - if (usersSingleActivity?.status === 'COMPLETED' && isStakeSection && resetEpoch && !lifeTime) { + const isUniV2EpochRelated = + typeof usersSingleActivity?.activityTypeId === 'string' && usersSingleActivity.activityTypeId.endsWith('v2_epoch'); + + const isEpochRelated = + usersSingleActivity?.data?.currentEpoch == pushStakeData?.currentEpoch || + usersSingleActivity?.data?.currentEpoch == uniV2StakeData?.currentEpoch; + + // claimed status for the same epoch + if (usersSingleActivity?.status === 'COMPLETED' && (isPushEpochRelated || isUniV2EpochRelated) && isEpochRelated) { + console.log('claimed in this epoch button'); + return ( + + ); + } + + // default verify button for stake epoch section + if (usersSingleActivity?.status === 'COMPLETED' && resetEpoch && (isPushEpochRelated || isUniV2EpochRelated)) { + console.log('reset button'); return ( - // default verify button = () => { flexDirection="column" gap="spacing-sm" > - - Bonus Activities - + + Bonus Activities + + }>NEW + {errorMessage && ( diff --git a/src/modules/rewards/components/RewardsActivitiesBottomSection.tsx b/src/modules/rewards/components/RewardsActivitiesBottomSection.tsx index 39b022b384..54b96a0aae 100644 --- a/src/modules/rewards/components/RewardsActivitiesBottomSection.tsx +++ b/src/modules/rewards/components/RewardsActivitiesBottomSection.tsx @@ -19,8 +19,6 @@ const RewardsActivitiesBottomSection: FC = > - - = display="flex" flexDirection="column" padding={{ ml: 'spacing-sm', initial: 'spacing-md' }} - margin="spacing-none spacing-none spacing-md spacing-none" > = subtitle="Visit [app.push.org/yield](https://app.push.org/yield) and stake tokens in the Fee Pool or LP Pool to activate multipliers." /> + + ); }; diff --git a/src/modules/rewards/components/RewardsActivityIcon.tsx b/src/modules/rewards/components/RewardsActivityIcon.tsx index 9a48f24553..4ce3744cc5 100644 --- a/src/modules/rewards/components/RewardsActivityIcon.tsx +++ b/src/modules/rewards/components/RewardsActivityIcon.tsx @@ -1,5 +1,4 @@ import { FC } from 'react'; - import { ActivePushPoints, BlueBonusActivitySubscribers, @@ -39,6 +38,7 @@ import { revokeLogo, pwnLogo, udLogo, + btcTrackerLogo, } from 'common'; import { ActvityType } from 'queries'; @@ -259,6 +259,17 @@ const RewardsActivityIcon: FC = ({ type }) => { ); } + if (type === 'channel_specific_subscriptions:BTC_PRICE_TRACKER_CHANNEL') { + return ( + + ); + } + if (type === 'atleast_5_defi_channel_specific_subscriptions') { return ( = ({ const usersSingleActivity = allUsersActivity?.[activity?.activityType] as UsersActivity; const isLoading = isAllActivitiesLoading; - const hasActivityEndedUnclaimed = usersSingleActivity?.status !== 'COMPLETED' && hasEpochEnded; + const hasActivityEndedUnclaimed = hasEpochEnded; const isLockedOrNotConnected = isLocked || !isWalletConnected; @@ -93,7 +93,11 @@ const StakePushActivitiesListItem: FC = ({ gap={{ ml: 'spacing-sm', initial: 'spacing-xxxs' }} alignItems={{ ml: 'center' }} > - + = ({ > {activity?.activityTitle} + {activity?.tags?.map((tag) => ( + } + > + {tag} + + ))} - + = ({ > {activity?.activityTitle} + {activity?.tags?.map((tag) => ( + } + > + {tag} + + ))} {activity.points > 0 && ( diff --git a/src/modules/rewards/components/StakePushSection.tsx b/src/modules/rewards/components/StakePushSection.tsx index 10cae3ed15..f3e6062b4e 100644 --- a/src/modules/rewards/components/StakePushSection.tsx +++ b/src/modules/rewards/components/StakePushSection.tsx @@ -25,7 +25,7 @@ export type StakePushPoints = { const StakePushSection: FC = ({ title, subtitle, timeline, lifeTime }) => { const { account, isWalletConnected } = useAccount(); const { isLocked } = useRewardsContext(); - const { stakePushArray, uniV2PushArray, isLoading, daysToReset } = useStakeRewardsResetTime({ + const { stakePushArray, uniV2PushArray, isLoading, daysToReset, refetchSendActivities } = useStakeRewardsResetTime({ lifeTime, }); const [errorMessage, setErrorMessage] = useState(''); @@ -184,7 +184,10 @@ const StakePushSection: FC = ({ title, subtitle, timeline, life hasEpochEnded={hasEpochEnded} allUsersActivity={allUsersActivity as StakeActivityResponse} isAllActivitiesLoading={isAllActivitiesLoading} - refetchActivity={refetchActivity} + refetchActivity={() => { + refetchActivity(); + refetchSendActivities(); + }} lifeTime={lifeTime} /> ))} diff --git a/src/modules/rewards/hooks/useDailyRewards.tsx b/src/modules/rewards/hooks/useDailyRewards.tsx index 366642bdd1..61a21d5e17 100644 --- a/src/modules/rewards/hooks/useDailyRewards.tsx +++ b/src/modules/rewards/hooks/useDailyRewards.tsx @@ -96,8 +96,20 @@ const useDailyRewards = () => { } } - setActiveDay(newDay); - setActiveItem(newDayData); + // first day data after completing all 7 + const firstDayData = dailyRewardsActivities?.find( + (activity) => activity.activityType === `daily_check_in_7_days_day1` + ); + + // if active day is complete, reset to first day, if not use the next day + if (newDay <= 7) { + setActiveDay(newDay); + setActiveItem(newDayData); + } else { + setActiveDay(1); + setActiveItem(firstDayData); + } + setIsLoadingRewards(false); }, [sendRecentActivities]); diff --git a/src/modules/rewards/hooks/useStakeRewardsResetTime.tsx b/src/modules/rewards/hooks/useStakeRewardsResetTime.tsx index 74cc6d5750..6e789562b2 100644 --- a/src/modules/rewards/hooks/useStakeRewardsResetTime.tsx +++ b/src/modules/rewards/hooks/useStakeRewardsResetTime.tsx @@ -65,7 +65,7 @@ const useStakeRewardsResetTime = ({ lifeTime }: StakeRewardsResetTime) => { const activityTitles = allPushArray?.map((activity) => activity.activityType); - const { data: sendRecentActivities } = useGetRewardActivityStatus( + const { data: sendRecentActivities, refetch: refetchSendActivities } = useGetRewardActivityStatus( { userId: userDetails?.userId as string, activities: activityTitles as string[], @@ -80,6 +80,7 @@ const useStakeRewardsResetTime = ({ lifeTime }: StakeRewardsResetTime) => { const differenceInSeconds = (resetDate as number) - currentTime; return Math.floor(differenceInSeconds / (60 * 60 * 24)); }, [resetDate]); + // const daysToReset = -2; // Helper function to check if 7 days have passed since the stored epoch time (in seconds) const hasSevenDaysPassed = (storedEpochTime: number) => { @@ -126,7 +127,8 @@ const useStakeRewardsResetTime = ({ lifeTime }: StakeRewardsResetTime) => { updateResetDate(latestTimestamp); } - if (!isEpochActive && isPastSevenDays) { + if (!isEpochActive) { + // if (!isEpochActive && isPastSevenDays) { setResetEpoch(true); console.log(`${stakeType} epoch is reset`); } else { @@ -135,8 +137,6 @@ const useStakeRewardsResetTime = ({ lifeTime }: StakeRewardsResetTime) => { } }; - // console.log(daysToReset, 'daysToReset'); - // Effect for handling fetch data for both arrays useEffect(() => { if ( @@ -154,7 +154,7 @@ const useStakeRewardsResetTime = ({ lifeTime }: StakeRewardsResetTime) => { } }, [userDetails?.userId, isWalletConnected, isLoadingPushStakeData, isLoadingPushUniData, sendRecentActivities]); - return { stakePushArray, uniV2PushArray, isLoading, daysToReset }; + return { stakePushArray, uniV2PushArray, isLoading, daysToReset, refetchSendActivities }; }; export { useStakeRewardsResetTime }; diff --git a/src/modules/rewards/utils/activityTypeArray.ts b/src/modules/rewards/utils/activityTypeArray.ts index 56968897bb..c8929d4873 100644 --- a/src/modules/rewards/utils/activityTypeArray.ts +++ b/src/modules/rewards/utils/activityTypeArray.ts @@ -21,6 +21,7 @@ export const channelSubscriptionActivities: ActvityType[] = [ 'channel_specific_subscriptions:REVOKE_NOTIFICATIONS_CHANNEL', 'channel_specific_subscriptions:PWN_NOTIFICATIONS_CHANNEL', 'channel_specific_subscriptions:UNSTOPPABLE_DOMAINS_CHANNEL', + 'channel_specific_subscriptions:BTC_PRICE_TRACKER_CHANNEL', ]; export const bonusRewardActivities: ActvityType[] = [ diff --git a/src/queries/hooks/chat/index.ts b/src/queries/hooks/chat/index.ts new file mode 100644 index 0000000000..11c0ddb952 --- /dev/null +++ b/src/queries/hooks/chat/index.ts @@ -0,0 +1 @@ +export * from './useGetGroupInfo'; diff --git a/src/queries/hooks/chat/useGetGroupInfo.ts b/src/queries/hooks/chat/useGetGroupInfo.ts new file mode 100644 index 0000000000..c23394e410 --- /dev/null +++ b/src/queries/hooks/chat/useGetGroupInfo.ts @@ -0,0 +1,26 @@ +import { useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { useSelector } from 'react-redux'; + +import { groupInfo } from '../../queryKeys'; +import { getGroupInfo } from '../../services'; + +import { UserStoreType } from 'types'; +import { GroupInfoResponse } from '../../types'; + +/** + * @param chainId + * @returns query response + */ +export const useGetGroupInfo = (chatId?: string, config?: Partial>) => { + const { userPushSDKInstance } = useSelector((state: UserStoreType) => { + return state.user; + }); + + const query = useQuery({ + queryKey: [groupInfo, userPushSDKInstance?.account, chatId], + enabled: !!chatId, + queryFn: () => getGroupInfo(userPushSDKInstance, chatId!), + ...config, + }); + return query; +}; diff --git a/src/queries/hooks/index.ts b/src/queries/hooks/index.ts index af7cf2c265..5ceff9be7e 100644 --- a/src/queries/hooks/index.ts +++ b/src/queries/hooks/index.ts @@ -1,5 +1,6 @@ export * from './createChannel'; export * from './channels'; +export * from './chat'; export * from './user'; export * from './rewards'; export * from './pointsVault'; diff --git a/src/queries/hooks/rewards/index.ts b/src/queries/hooks/rewards/index.ts index ee6ba806a3..7609e40628 100644 --- a/src/queries/hooks/rewards/index.ts +++ b/src/queries/hooks/rewards/index.ts @@ -7,4 +7,5 @@ export * from './useCreateRewardsUser'; export * from './useGetRewardsLedearboard'; export * from './useGetRewardActivityStatus'; export * from './useGetPushStakeEpoch'; +export * from './useGetPreviousPushStakeEpoch'; export * from './useGetUniV2StakeEpoch'; diff --git a/src/queries/hooks/rewards/useGetPreviousPushStakeEpoch.ts b/src/queries/hooks/rewards/useGetPreviousPushStakeEpoch.ts new file mode 100644 index 0000000000..0b1114130e --- /dev/null +++ b/src/queries/hooks/rewards/useGetPreviousPushStakeEpoch.ts @@ -0,0 +1,9 @@ +import { useQuery } from '@tanstack/react-query'; +import { getPreviousPushStakeEpoch } from 'queries'; +import { pushPreviousStakeEpoch } from 'queries/queryKeys'; + +export const useGetPreviousPushStakeEpoch = () => + useQuery({ + queryKey: [pushPreviousStakeEpoch], + queryFn: getPreviousPushStakeEpoch, + }); diff --git a/src/queries/hooks/user/index.ts b/src/queries/hooks/user/index.ts index 74c502c479..8b2966f7e5 100644 --- a/src/queries/hooks/user/index.ts +++ b/src/queries/hooks/user/index.ts @@ -7,3 +7,4 @@ export * from './useUpdateUserProfileInfo'; export * from './useSendHandlesVerificationCode'; export * from './useVerifyHandlesVerificationCode'; export * from './useGetSocialsStatus'; +export * from './useGetUserProfileDetails'; diff --git a/src/queries/hooks/user/useGetUserProfileDetails.ts b/src/queries/hooks/user/useGetUserProfileDetails.ts new file mode 100644 index 0000000000..f109872ef4 --- /dev/null +++ b/src/queries/hooks/user/useGetUserProfileDetails.ts @@ -0,0 +1,29 @@ +import { useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { useSelector } from 'react-redux'; + +import { userProfileDetails } from '../../queryKeys'; +import { getUserProfileDetails } from '../../services'; + +import { UserStoreType } from 'types'; +import { UserProfileDetailsResponse } from '../../types'; + +/** + * @param userAddress + * @returns query response + */ +export const useGetUserProfileDetails = ( + userAddress?: string, + config?: Partial> +) => { + const { userPushSDKInstance } = useSelector((state: UserStoreType) => { + return state.user; + }); + + const query = useQuery({ + queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress], + enabled: !!userAddress, + queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress!), + ...config, + }); + return query; +}; diff --git a/src/queries/models/chat/getGroupInfoModelCreator.ts b/src/queries/models/chat/getGroupInfoModelCreator.ts new file mode 100644 index 0000000000..520141820c --- /dev/null +++ b/src/queries/models/chat/getGroupInfoModelCreator.ts @@ -0,0 +1,4 @@ +import { GroupInfoResponse } from '../../types'; + +//any remodelling needed in the response can be done here +export const getGroupInfoModelCreator = (response: GroupInfoResponse): GroupInfoResponse => response; diff --git a/src/queries/models/chat/index.ts b/src/queries/models/chat/index.ts new file mode 100644 index 0000000000..09b7b550d4 --- /dev/null +++ b/src/queries/models/chat/index.ts @@ -0,0 +1 @@ +export * from './getGroupInfoModelCreator'; diff --git a/src/queries/models/index.ts b/src/queries/models/index.ts index fdcb1f07a9..66edccfb44 100644 --- a/src/queries/models/index.ts +++ b/src/queries/models/index.ts @@ -2,3 +2,4 @@ export * from './channels'; export * from './user'; export * from './rewards'; export * from './pointsVault'; +export * from './chat'; diff --git a/src/queries/models/rewards/getPreviousPushStakeEpochModel.ts b/src/queries/models/rewards/getPreviousPushStakeEpochModel.ts new file mode 100644 index 0000000000..0184e1d452 --- /dev/null +++ b/src/queries/models/rewards/getPreviousPushStakeEpochModel.ts @@ -0,0 +1,3 @@ +import { RewardsStakeParams } from 'queries/types'; + +export const getPreviousPushStakeEpochModel = (response: RewardsStakeParams): RewardsStakeParams => response; diff --git a/src/queries/models/rewards/index.ts b/src/queries/models/rewards/index.ts index cb8c48e292..f6d00ceca4 100644 --- a/src/queries/models/rewards/index.ts +++ b/src/queries/models/rewards/index.ts @@ -7,4 +7,5 @@ export * from './createUserRewardsDetailsModel'; export * from './getRewardsLeaderboardModalCreator'; export * from './getRewardActivityStatusModel'; export * from './getPushStakeEpochModel'; +export * from './getPreviousPushStakeEpochModel'; export * from './getUniV2StakeEpochModel'; diff --git a/src/queries/models/user/getUserProfileDetailsModelCreator.ts b/src/queries/models/user/getUserProfileDetailsModelCreator.ts new file mode 100644 index 0000000000..c44fc6bf87 --- /dev/null +++ b/src/queries/models/user/getUserProfileDetailsModelCreator.ts @@ -0,0 +1,5 @@ +import { UserProfileDetailsResponse } from '../../types'; + +//any remodelling needed in the response can be done here +export const getUserProfileDetailsModelCreator = (response: UserProfileDetailsResponse): UserProfileDetailsResponse => + response; diff --git a/src/queries/models/user/index.ts b/src/queries/models/user/index.ts index c95226b09e..49ad9da1f6 100644 --- a/src/queries/models/user/index.ts +++ b/src/queries/models/user/index.ts @@ -3,3 +3,4 @@ export * from './getUserProfileInfoModelCreator'; export * from './sendHandlesVerificationCodeModelCreator'; export * from './verifyHandlesVerificationCodeModelCreator'; export * from './getSocialsStatusModelCreator'; +export * from './getUserProfileDetailsModelCreator'; diff --git a/src/queries/queryKeys.ts b/src/queries/queryKeys.ts index 0c975f2fb4..6b531599c0 100644 --- a/src/queries/queryKeys.ts +++ b/src/queries/queryKeys.ts @@ -18,12 +18,14 @@ export const creatingNewChannel = 'creatingNewChannel'; export const deactivatingChannel = 'deactivatingChannel'; export const discordDetails = 'discordDetails'; export const generateUserIdByWallet = 'generateUserIdByWallet'; +export const groupInfo = 'groupInfo'; export const initiateNewChain = 'initiateNewChain'; export const pointsVaultApprovedUsers = 'pointsVaultApprovedUsers'; export const pointsVaultPendingUsers = 'pointsVaultPendingUsers'; export const pointsVaultRejectedUsers = 'pointsVaultRejectedUsers'; export const pointsVaultSearch = 'pointsVaultSearch'; export const pointsVaultUserLoginKey = 'pointsVaultUserLogin'; +export const pushPreviousStakeEpoch = 'pushPreviousStakeEpoch'; export const pushStakeEpoch = 'pushStakeEpoch'; export const reactivatingChannel = 'reactivatingChannel'; export const rejectVaultUser = 'rejectVaultUser'; @@ -50,4 +52,5 @@ export const UserRewardsDetails = 'userRewardsDetails'; export const userSocialStatus = 'userSocialStatus'; export const userSubscription = 'userSubscription'; export const userTwitterDetails = 'userTwitterDetails'; +export const userProfileDetails = 'userProfileDetails'; export const verifyAliasChain = 'verifyAliasChain'; diff --git a/src/queries/services/chat/getGroupInfo.ts b/src/queries/services/chat/getGroupInfo.ts new file mode 100644 index 0000000000..61b0724718 --- /dev/null +++ b/src/queries/services/chat/getGroupInfo.ts @@ -0,0 +1,5 @@ +import { PushAPI } from '@pushprotocol/restapi'; +import { getGroupInfoModelCreator } from '../../models'; + +export const getGroupInfo = (userPushSDKInstance: PushAPI, chatId: string) => + userPushSDKInstance.chat.group.info(chatId).then(getGroupInfoModelCreator); diff --git a/src/queries/services/chat/index.ts b/src/queries/services/chat/index.ts new file mode 100644 index 0000000000..df1c03bbc6 --- /dev/null +++ b/src/queries/services/chat/index.ts @@ -0,0 +1 @@ +export * from './getGroupInfo'; diff --git a/src/queries/services/index.ts b/src/queries/services/index.ts index 632b38dfaa..0697336462 100644 --- a/src/queries/services/index.ts +++ b/src/queries/services/index.ts @@ -5,3 +5,4 @@ export * from './pointsVault'; export * from './createChannel'; export * from './analytics'; export * from './notificationSettings'; +export * from './chat'; diff --git a/src/queries/services/rewards/getPreviousPushStakeEpoch.ts b/src/queries/services/rewards/getPreviousPushStakeEpoch.ts new file mode 100644 index 0000000000..45d6f69045 --- /dev/null +++ b/src/queries/services/rewards/getPreviousPushStakeEpoch.ts @@ -0,0 +1,10 @@ +import axios from 'axios'; + +import { getRewardsBaseURL } from '../../baseURL'; +import { getPreviousPushStakeEpochModel } from 'queries/models'; + +export const getPreviousPushStakeEpoch = () => + axios({ + method: 'GET', + url: `${getRewardsBaseURL()}/staking/push/previous-epoch-blocks`, + }).then((response) => getPreviousPushStakeEpochModel(response.data)); diff --git a/src/queries/services/rewards/index.ts b/src/queries/services/rewards/index.ts index 85434d4bd6..61f7d46820 100644 --- a/src/queries/services/rewards/index.ts +++ b/src/queries/services/rewards/index.ts @@ -7,4 +7,5 @@ export * from './createUserRewardsDetail.ts'; export * from './getRewardsLeaderboard'; export * from './getRewardActivityStatus.ts'; export * from './getPushStakeEpoch.ts'; +export * from './getPreviousPushStakeEpoch.ts'; export * from './getUniV2StakeEpoch.ts'; diff --git a/src/queries/services/user/getUserProfileDetails.ts b/src/queries/services/user/getUserProfileDetails.ts new file mode 100644 index 0000000000..0cc61ff422 --- /dev/null +++ b/src/queries/services/user/getUserProfileDetails.ts @@ -0,0 +1,5 @@ +import { PushAPI } from '@pushprotocol/restapi'; +import { getUserProfileDetailsModelCreator } from 'queries/models'; + +export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address: string) => + userPushSDKInstance.profile.info({ overrideAccount: address }).then(getUserProfileDetailsModelCreator); diff --git a/src/queries/services/user/index.ts b/src/queries/services/user/index.ts index 89072fa57d..75b30c5c83 100644 --- a/src/queries/services/user/index.ts +++ b/src/queries/services/user/index.ts @@ -7,3 +7,4 @@ export * from './updateUserProfileInfo'; export * from './sendHandlesVerificationCode'; export * from './verifyHandlesVerificationCode'; export * from './getUserSocialsStatus'; +export * from './getUserProfileDetails'; diff --git a/src/queries/types/chat.ts b/src/queries/types/chat.ts new file mode 100644 index 0000000000..1d742c1797 --- /dev/null +++ b/src/queries/types/chat.ts @@ -0,0 +1,3 @@ +import { GroupDTO, GroupInfoDTO } from '@pushprotocol/restapi'; + +export type GroupInfoResponse = GroupDTO | GroupInfoDTO; diff --git a/src/queries/types/index.ts b/src/queries/types/index.ts index a99590a6c3..05869cb58f 100644 --- a/src/queries/types/index.ts +++ b/src/queries/types/index.ts @@ -4,3 +4,4 @@ export * from './rewards'; export * from './pointsVault'; export * from './createChannel'; export * from './notificationsettings'; +export * from './chat'; diff --git a/src/queries/types/rewards.ts b/src/queries/types/rewards.ts index ca9b94d69c..aa976edca9 100644 --- a/src/queries/types/rewards.ts +++ b/src/queries/types/rewards.ts @@ -32,6 +32,7 @@ export type ActvityType = | 'daily_check_in_7_days_day5' | 'daily_check_in_7_days_day6' | 'daily_check_in_7_days_day7' + | 'channel_specific_subscriptions:BTC_PRICE_TRACKER_CHANNEL' | 'channel_specific_subscriptions:QUICKSWAP_CHANNEL' | 'channel_specific_subscriptions:WALLETTRACKER_CHANNEL' | 'channel_specific_subscriptions:PRICETRACKER_CHANNEL' @@ -93,7 +94,10 @@ export type UsersActivity = { activityId: string; userId: string; activityTypeId: string; - data: { twitter?: string; discord?: string }; + data: + | { twitter?: string; discord?: string } + | { currentEpoch?: number; fromBlock?: number; toBlock?: number; fromTimestamp?: number; toTimestamp?: number } + | any; status: 'COMPLETED' | 'PENDING' | 'REJECTED'; points: number; multiplier: number; diff --git a/src/queries/types/user.ts b/src/queries/types/user.ts index 3c6a3e2f87..9a393c2633 100644 --- a/src/queries/types/user.ts +++ b/src/queries/types/user.ts @@ -63,4 +63,13 @@ export type UserSocialStatusResponse = { email: string | null; telegram_username: string | null; discord_username: string | null; + }; + +export type UserProfileDetailsResponse = { + blockedUsersList: Array; + desc: string | null; + name: string | null; + picture: string; + profileVerificationProof: string | null; }; + diff --git a/yarn.lock b/yarn.lock index 96543abe1c..9d90fc1436 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3952,9 +3952,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/restapi@npm:1.7.25": - version: 1.7.25 - resolution: "@pushprotocol/restapi@npm:1.7.25" +"@pushprotocol/restapi@npm:1.7.29": + version: 1.7.29 + resolution: "@pushprotocol/restapi@npm:1.7.29" dependencies: "@metamask/eth-sig-util": "npm:^5.0.2" axios: "npm:^0.27.2" @@ -3977,7 +3977,7 @@ __metadata: peerDependenciesMeta: ethers: optional: true - checksum: 10/1da9268e81c3038871904336f16b6161fb039e9d0995a060f403f95c553a8ca8c9faada73c1806fb8ba3557cbdcc33b53c0e223c4cb743ddc9ed24da0b91c992 + checksum: 10/13afab4147598627c470f09706b859af116ffd4831bbb4de1e2f6b3490b5c10f5f06754b820a766614ac145912b9a455c974570a2763b82289aa57f37d55421a languageName: node linkType: hard @@ -3993,9 +3993,9 @@ __metadata: languageName: node linkType: hard -"@pushprotocol/uiweb@npm:1.7.1": - version: 1.7.1 - resolution: "@pushprotocol/uiweb@npm:1.7.1" +"@pushprotocol/uiweb@npm:1.7.2": + version: 1.7.2 + resolution: "@pushprotocol/uiweb@npm:1.7.2" dependencies: "@livekit/components-react": "npm:^1.2.2" "@livekit/components-styles": "npm:^1.0.6" @@ -4029,7 +4029,7 @@ __metadata: react-twitter-embed: "npm:^4.0.4" uuid: "npm:^9.0.1" peerDependencies: - "@pushprotocol/restapi": 1.7.25 + "@pushprotocol/restapi": 1.7.29 "@pushprotocol/socket": ^0.5.0 axios: ^0.27.2 openpgp: ^5.8.0 @@ -4037,7 +4037,7 @@ __metadata: react-dom: 17.0.2 styled-components: ^6.0.8 viem: ^1.3.0 - checksum: 10/218d56a0f9df43755ae8988cec94e93af7c8c4b5db5c88acee3a9062e0a6c1cbb510e43cd7706cf1b679964bf9cee6148f62e69f4d932560bfd1d6cdea785b8a + checksum: 10/8594689a4c814dae1cbc43500ae6e16e04a3cdadfc0b81130796ad06f64268e6b8ff986686323911266700972ec3a64870b335a97ed4e8766e826cbc504f13cf languageName: node linkType: hard @@ -18347,9 +18347,9 @@ __metadata: "@metamask/eth-sig-util": "npm:^4.0.0" "@mui/icons-material": "npm:^5.8.4" "@mui/material": "npm:^5.5.0" - "@pushprotocol/restapi": "npm:1.7.25" + "@pushprotocol/restapi": "npm:1.7.29" "@pushprotocol/socket": "npm:0.5.3" - "@pushprotocol/uiweb": "npm:1.7.1" + "@pushprotocol/uiweb": "npm:1.7.2" "@radix-ui/react-dialog": "npm:^1.1.1" "@radix-ui/react-dropdown-menu": "npm:^2.1.1" "@radix-ui/react-switch": "npm:^1.1.0"