diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx index b8633c48e..b4ca4f21b 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx @@ -1,65 +1,66 @@ -import { ChatPreview } from "@pushprotocol/uiweb"; +import { ChatPreview } from '@pushprotocol/uiweb'; const ChatPreviewTest = () => { + return ( +
+ + + +
+ ); +}; - return ( -
- - - -
- ) -} - -export default ChatPreviewTest; \ No newline at end of file +export default ChatPreviewTest; diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx index 66aab03ef..832ae2461 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreviewList.tsx @@ -191,9 +191,6 @@ const ChatPreviewListTest = () => { onPreload={(chats) => { console.log('preload chats are: ', chats); }} - // prefillChatPreviewList={prefill} - // listType='SEARCH' - // searchParamter='c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e' /> diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatProfile.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatProfile.tsx index b39abfe8f..c51afedc0 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatProfile.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatProfile.tsx @@ -1,4 +1,5 @@ import { ChatProfile } from '@pushprotocol/uiweb'; +import { CHAT_ID } from '../constants'; export const ChatProfileTest = () => { return ( @@ -6,8 +7,7 @@ export const ChatProfileTest = () => { left component} chatProfileRightHelperComponent={
right component
} - chatId="monalisha.wallet" - // chatId='36baf37e441fdd94e23406c6c716fc4e91a93a9ee68e070cd5b054534dbe09a6' + chatId={CHAT_ID} /> ); diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx index e5c68d7cf..66beffbd1 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewComponent.tsx @@ -1,14 +1,9 @@ import styled from 'styled-components'; -import { - ChatView, - CreateGroupModal, - MODAL_BACKGROUND_TYPE, - MODAL_POSITION_TYPE, - UserProfile, -} from '@pushprotocol/uiweb'; +import { ChatView, MODAL_BACKGROUND_TYPE } from '@pushprotocol/uiweb'; import { Section } from '../components/StyledComponents'; import Img from '../../assets/epnsLogo.png'; +import { CHAT_ID } from '../constants'; const ChatViewComponentTest = () => { const chatFilterList = [ @@ -20,16 +15,12 @@ const ChatViewComponentTest = () => {

Chat View Test page

- {/* { - console.log('in close'); - }} - /> */} + {/* uncomment the below code to test create group modal */} {/* {console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/> */} console.log('Verification Failed')} - chatId="34c44214589cecc176a136ee1daf0f0231ecc6d6574b920b5ae39eb971fa3cb4" + chatId={CHAT_ID} chatProfileLeftHelperComponent={ console.debug('clicked')} /> } @@ -37,19 +28,6 @@ const ChatViewComponentTest = () => { limit={10} isConnected={true} groupInfoModalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} - // groupInfoModalPositionType={MODAL_POSITION_TYPE.RELATIVE} - // verificationFailModalPosition={MODAL_POSITION_TYPE.RELATIVE} - - // welcomeComponent={
- //

Welcome

- //

new chat

- //

Welcome

- //

new chat

- //

Welcome

- //

new chat

- //

Welcome

- - //
} />
@@ -62,5 +40,3 @@ const ChatViewComponentCard = styled(Section)` height: 80vh; position: relative; `; -//c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e -//4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68 diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewListTest.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewListTest.tsx index 400228016..2e18a4816 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewListTest.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatViewListTest.tsx @@ -1,44 +1,25 @@ -import { useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; -import * as PUSHAPI from '@pushprotocol/restapi'; -import { Link } from 'react-router-dom'; -import { Section } from '../components/StyledComponents'; -import { ChatViewList } from '@pushprotocol/uiweb'; -import { EnvContext, Web3Context } from '../context'; -import { usePushChatSocket } from '@pushprotocol/uiweb'; -import { MessageInput } from '@pushprotocol/uiweb'; +import { ChatViewList } from '@pushprotocol/uiweb'; +import { CHAT_ID } from '../constants'; const ChatViewListTest = () => { - // const { account, pgpPrivateKey } = useContext(Web3Context) - - // const { env } = useContext(EnvContext); - - - // usePushChatSocket(); - - return (

Chat UI Test page

- {/* */} - - - + - {/* */}
); }; export default ChatViewListTest; - const ChatViewListCard = styled.div` -height:40vh; -background:black; -overflow: auto; -overflow-x: hidden; -`; \ No newline at end of file + height: 40vh; + background: black; + overflow: auto; + overflow-x: hidden; +`; diff --git a/packages/examples/sdk-frontend-react/src/app/app.tsx b/packages/examples/sdk-frontend-react/src/app/app.tsx index 57d3ab843..80f7dd776 100644 --- a/packages/examples/sdk-frontend-react/src/app/app.tsx +++ b/packages/examples/sdk-frontend-react/src/app/app.tsx @@ -340,13 +340,7 @@ export function App() { - + = (options: IChatViewLis return () => clearTimeout(timer); } - - return () => {}; }, [chatAcceptStream, participantJoinStream]); // Change listtype to 'UINITIALIZED' and hidden to true when participantRemoveStream or participantLeaveStream is received diff --git a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx index c4dea01db..d5457ba77 100644 --- a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx +++ b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx @@ -1,9 +1 @@ export { ConnectButton } from './ConnectButton'; - -// interface IConnectButtonCompProps { -// autoConnect?: boolean; -// } - -// export const ConnectButtonComp: React.FC = ({ autoConnect }) => { -// return ; -// }; diff --git a/packages/uiweb/src/lib/components/widget/helpers/notifications.ts b/packages/uiweb/src/lib/components/widget/helpers/notifications.ts index cc139590a..af441f4a9 100644 --- a/packages/uiweb/src/lib/components/widget/helpers/notifications.ts +++ b/packages/uiweb/src/lib/components/widget/helpers/notifications.ts @@ -2,13 +2,10 @@ import { NotificationSettingType, UserSetting } from '@pushprotocol/restapi'; const isSettingType1 = (setting: NotificationSettingType) => setting.type === 1; -export const notifUserSettingFormatString = ({ - settings, -}: { - settings: NotificationSettingType[]; -}) => { +export const notifUserSettingFormatString = ({ settings }: { settings: NotificationSettingType[] }) => { const _notifSettings: UserSetting[] = []; settings && + settings.length && settings.forEach((setting) => isSettingType1(setting) ? _notifSettings.push({ @@ -21,38 +18,32 @@ export const notifUserSettingFormatString = ({ ); return _notifSettings; }; -export const notifStrictUserSettingFromat = ({ - settings, -}: { - settings: NotificationSettingType[]; -}) => { +export const notifStrictUserSettingFromat = ({ settings }: { settings: NotificationSettingType[] }) => { const _notifSettings: NotificationSettingType[] = []; settings && - settings.forEach((setting) => - isSettingType1(setting) - ? _notifSettings.push({ - ...setting, - userPreferance: setting?.userPreferance?? {value:0,enabled:false}, - }) - : _notifSettings.push({ - ...setting, - userPreferance: setting?.userPreferance?? { - value: setting.default ||0, - enabled: false, - } - }) - ); + settings.length && + settings.forEach((setting) => + isSettingType1(setting) + ? _notifSettings.push({ + ...setting, + userPreferance: setting?.userPreferance ?? { value: 0, enabled: false }, + }) + : _notifSettings.push({ + ...setting, + userPreferance: setting?.userPreferance ?? { + value: setting.default || 0, + enabled: false, + }, + }) + ); return _notifSettings; }; -export const notifUserSettingFromChannelSetting = ({ - settings -}: { - settings: any[]; -}) => { +export const notifUserSettingFromChannelSetting = ({ settings }: { settings: any[] }) => { const _userSettings: NotificationSettingType[] = []; settings && + settings.length && settings.forEach((setting) => isSettingType1(setting) ? _userSettings.push({ diff --git a/packages/uiweb/src/lib/components/widget/subscriptionManager/ManageNotificationComponent.tsx b/packages/uiweb/src/lib/components/widget/subscriptionManager/ManageNotificationComponent.tsx index 85cb30ada..d54ed4d3d 100644 --- a/packages/uiweb/src/lib/components/widget/subscriptionManager/ManageNotificationComponent.tsx +++ b/packages/uiweb/src/lib/components/widget/subscriptionManager/ManageNotificationComponent.tsx @@ -39,7 +39,7 @@ export const ManageNotficationsComponent: React.FC { const { userSettings, channelAddress, channelInfo, handleNext, autoconnect = false } = options || {}; - const [modifiedSettings, setModifiedSettings] = useState([...userSettings]); + const [modifiedSettings, setModifiedSettings] = useState([...userSettings]); const { unsubscribeError, unsubscribeLoading, diff --git a/packages/uiweb/src/lib/components/widget/subscriptionManager/SettingsComponents.tsx b/packages/uiweb/src/lib/components/widget/subscriptionManager/SettingsComponents.tsx index dcf39c519..cae76f5f1 100644 --- a/packages/uiweb/src/lib/components/widget/subscriptionManager/SettingsComponents.tsx +++ b/packages/uiweb/src/lib/components/widget/subscriptionManager/SettingsComponents.tsx @@ -19,20 +19,13 @@ interface IThemeProps { interface ISettingsComponentProps { settings: PushAPI.NotificationSettingType[]; - setSettings: React.Dispatch< - React.SetStateAction - >; + setSettings: React.Dispatch>; } -export const SettingsComponent: React.FC = ( - options: ISettingsComponentProps -) => { +export const SettingsComponent: React.FC = (options: ISettingsComponentProps) => { const theme = useContext(ThemeContext); const { settings = [], setSettings } = options || {}; - const handleSliderChange = ( - index: number, - value: number | { lower: number; upper: number } - ) => { + const handleSliderChange = (index: number, value: number | { lower: number; upper: number }) => { const updatedSettings = [...settings]; updatedSettings[index].userPreferance!.value = value; @@ -41,9 +34,8 @@ export const SettingsComponent: React.FC = ( const handleToggleChange = (index: number) => { const updatedSettings = [...settings]; - if(updatedSettings[index]?.userPreferance) - updatedSettings[index].userPreferance!.enabled = - !updatedSettings[index].userPreferance!.enabled; + if (updatedSettings[index]?.userPreferance) + updatedSettings[index].userPreferance!.enabled = !updatedSettings[index].userPreferance!.enabled; setSettings(updatedSettings); }; return ( @@ -53,11 +45,12 @@ export const SettingsComponent: React.FC = ( gap="15px" width="100%" maxHeight="200px" - justifyContent='start' + justifyContent="start" overflow="hidden scroll" > - {settings.map( - (setting: PushAPI.NotificationSettingType, index: number) => ( + {settings && + settings?.length && + settings?.map((setting: PushAPI.NotificationSettingType, index: number) => ( = ( {(setting.type == 2 || setting.type == 1) && ( { handleToggleChange(index); }} /> )} - {setting.type == 2 && setting?.userPreferance?.enabled && ( = ( onChange={({ x }) => handleSliderChange(index, x)} /> )} + {/* uncomment this when we need this to be included in the settings feature + not needed as of now */} {/* {setting.type == 3 && setting?.userPreferance?.enabled && ( = ( /> )} */} - ) - )} + ))} ); }; const SettingsSection = styled(Section)` - border-bottom: ${(props) => - props.divider ? props.theme.border?.divider : 'none'}; + border-bottom: ${(props) => (props.divider ? props.theme.border?.divider : 'none')}; padding-bottom: 15px; `; const ScrollSection = styled(Section)<{ theme: IWidgetTheme }>` diff --git a/packages/uiweb/src/lib/components/widget/subscriptionManager/SubscribeComponent.tsx b/packages/uiweb/src/lib/components/widget/subscriptionManager/SubscribeComponent.tsx index 250042386..dff1838d6 100644 --- a/packages/uiweb/src/lib/components/widget/subscriptionManager/SubscribeComponent.tsx +++ b/packages/uiweb/src/lib/components/widget/subscriptionManager/SubscribeComponent.tsx @@ -37,12 +37,12 @@ export const SubscribeComponent: React.FC = (options: const theme = useContext(ThemeContext); const { signer, setAccount, setSigner, user, account } = useWidgetData(); const subscribeToast = useToast(); - const [modifiedSettings, setModifiedSettings] = useState( + const [modifiedSettings, setModifiedSettings] = useState( useMemo(() => { if (channelInfo && channelInfo?.channel_settings) { return notifUserSettingFromChannelSetting({ settings: JSON.parse(channelInfo?.channel_settings) }); } - return null; + return []; }, [channelInfo]) ); @@ -51,7 +51,7 @@ export const SubscribeComponent: React.FC = (options: const response = await subscribeToChannel({ channelAddress: channelAddress, channelSettings: notifUserSettingFormatString({ - settings: modifiedSettings!, + settings: modifiedSettings, }), }); if (response && response?.status === 204) { diff --git a/packages/uiweb/src/lib/dataProviders/Web3OnboardDataProvider.tsx b/packages/uiweb/src/lib/dataProviders/Web3OnboardDataProvider.tsx index d1c5f02fe..0e1997857 100644 --- a/packages/uiweb/src/lib/dataProviders/Web3OnboardDataProvider.tsx +++ b/packages/uiweb/src/lib/dataProviders/Web3OnboardDataProvider.tsx @@ -7,8 +7,9 @@ import walletConnectModule from '@web3-onboard/walletconnect'; import init from '@web3-onboard/core'; import PushIcon from '../icons/Bell.svg'; import { ReactNode } from 'react'; +import { AppMetaDataType, ChainType } from '../types'; -const APP_META_DATA = { +const APP_META_DATA: AppMetaDataType = { name: 'Push Protocol', logo: PushIcon, icon: PushIcon, @@ -24,7 +25,7 @@ const wcv2InitOptions = { const walletConnect = walletConnectModule(wcv2InitOptions); const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true }); -const CHAINS = [ +const CHAINS: ChainType[] = [ { id: '0x1', token: 'ETH', diff --git a/packages/uiweb/src/lib/types/index.ts b/packages/uiweb/src/lib/types/index.ts index d46024476..e9267943f 100644 --- a/packages/uiweb/src/lib/types/index.ts +++ b/packages/uiweb/src/lib/types/index.ts @@ -127,12 +127,12 @@ export const SIDEBAR_PLACEHOLDER_KEYS = { NEW_CHAT: 'NEW_CHAT', } as const; -export type SidebarPlaceholderKeys = typeof SIDEBAR_PLACEHOLDER_KEYS[keyof typeof SIDEBAR_PLACEHOLDER_KEYS]; +export type SidebarPlaceholderKeys = (typeof SIDEBAR_PLACEHOLDER_KEYS)[keyof typeof SIDEBAR_PLACEHOLDER_KEYS]; -export type LocalStorageKeys = typeof LOCAL_STORAGE_KEYS[keyof typeof LOCAL_STORAGE_KEYS]; -export type PushTabs = typeof PUSH_TABS[keyof typeof PUSH_TABS]; -export type PushSubTabs = typeof PUSH_SUB_TABS[keyof typeof PUSH_SUB_TABS]; -export type SocketType = typeof SOCKET_TYPE[keyof typeof SOCKET_TYPE]; +export type LocalStorageKeys = (typeof LOCAL_STORAGE_KEYS)[keyof typeof LOCAL_STORAGE_KEYS]; +export type PushTabs = (typeof PUSH_TABS)[keyof typeof PUSH_TABS]; +export type PushSubTabs = (typeof PUSH_SUB_TABS)[keyof typeof PUSH_SUB_TABS]; +export type SocketType = (typeof SOCKET_TYPE)[keyof typeof SOCKET_TYPE]; export interface FileMessageContent { content: string; @@ -215,3 +215,22 @@ export interface IFrame { frameDetails?: FrameDetails; message?: string; } + +export type WalletType = { + name: string; + url: string; +}; + +export type AppMetaDataType = { + name: string; + logo: string; + icon: string; + description: string; + recommendedInjectedWallets: WalletType[]; +}; +export type ChainType = { + id: string; // Assuming all IDs are in hexadecimal string format + token: string; + label: string; + rpcUrl: string; +};