From 16008414e4180a14d7d7ac351526b1c6d0d09bc8 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Mon, 12 Feb 2024 15:49:27 -0700 Subject: [PATCH] Updates Fix up some styles --- src/components/GroupListItem.tsx | 2 +- src/components/modals/GroupInfoModal.tsx | 44 ++++++++++++++---------- src/hooks/useGroupContactInfo.ts | 13 +++++-- src/i18n/locales/en.json | 5 ++- src/screens/ConversationListScreen.tsx | 5 ++- src/screens/SearchScreen.tsx | 15 +++++++- 6 files changed, 57 insertions(+), 27 deletions(-) diff --git a/src/components/GroupListItem.tsx b/src/components/GroupListItem.tsx index 271b2f8..96fb109 100644 --- a/src/components/GroupListItem.tsx +++ b/src/components/GroupListItem.tsx @@ -39,7 +39,7 @@ export const GroupListItem: FC = ({ {groupDisplayName} diff --git a/src/components/modals/GroupInfoModal.tsx b/src/components/modals/GroupInfoModal.tsx index 281973b..bf3ec81 100644 --- a/src/components/modals/GroupInfoModal.tsx +++ b/src/components/modals/GroupInfoModal.tsx @@ -1,6 +1,7 @@ import {Group} from '@xmtp/react-native-sdk/build/lib/Group'; import {HStack, Pressable, VStack} from 'native-base'; import React, {FC, useCallback} from 'react'; +import {AppConfig} from '../../consts/AppConfig'; import {useContactInfo} from '../../hooks/useContactInfo'; import {translate} from '../../i18n'; import {colors} from '../../theme/colors'; @@ -24,7 +25,10 @@ const GroupParticipant: React.FC<{ }> = ({address, onRemove}) => { const {displayName, avatarUrl} = useContactInfo(address); return ( - + {displayName} @@ -39,23 +43,27 @@ const GroupParticipant: React.FC<{ - {translate('domain_origin')} - + {AppConfig.LENS_ENABLED && ( + <> + {translate('domain_origin')} + + + )} ); }; diff --git a/src/hooks/useGroupContactInfo.ts b/src/hooks/useGroupContactInfo.ts index 6f20bec..236f2d8 100644 --- a/src/hooks/useGroupContactInfo.ts +++ b/src/hooks/useGroupContactInfo.ts @@ -8,6 +8,7 @@ import { } from '../services/mmkvStorage'; import {formatAddress} from '../utils/formatAddress'; import {getEnsInfo} from '../utils/getEnsInfo'; +import {useClient} from './useClient'; type GroupContactInfoState = Record< string, @@ -22,6 +23,7 @@ export const useGroupContactInfo = (addresses: string[]) => { const [state, setState] = useState({}); const supportedChains = useSupportedChains(); const {clientId} = useWalletContext(); + const {client} = useClient(); useEffect(() => { addresses.forEach(address => { @@ -76,11 +78,16 @@ export const useGroupContactInfo = (addresses: string[]) => { let groupDisplayName = ''; - Object.values(state).forEach(it => { + Object.values(state).forEach((it, index) => { arr.push(it); - groupDisplayName += it.displayName + ', '; + if (it.address === client?.address) { + return; + } + groupDisplayName += + it.displayName + + (index === Object.values(state).length - 1 ? '' : ', '); }); return {groupDisplayName, data: arr}; - }, [state]); + }, [client?.address, state]); return data; }; diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index a40e49a..17863bd 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -68,5 +68,8 @@ "get_groups": "Get Groups", "get_contacts": "Get Contacts", - "discover": "Discover" + "discover": "Discover", + + "valid_address": "Valid Ethereum Address", + "message_requests_from_new_addresses": "Message requests from addresses you’ve never interacted with show up here" } diff --git a/src/screens/ConversationListScreen.tsx b/src/screens/ConversationListScreen.tsx index d75c046..db30ec5 100644 --- a/src/screens/ConversationListScreen.tsx +++ b/src/screens/ConversationListScreen.tsx @@ -94,7 +94,7 @@ const ListHeader: FC = ({ } }, [navigate]); return ( - + = ({ typography="text-caption/regular" textAlign={'center'} color={colors.actionAlertText}> - Message requests from addresses you’ve never interacted with show up - here + {translate('message_requests_from_new_addresses')} ) : messageRequestCount > 0 ? ( diff --git a/src/screens/SearchScreen.tsx b/src/screens/SearchScreen.tsx index 0c9c91e..da65ef7 100644 --- a/src/screens/SearchScreen.tsx +++ b/src/screens/SearchScreen.tsx @@ -1,4 +1,4 @@ -import {getAddress} from 'ethers/lib/utils'; +import {getAddress, isAddress} from 'ethers/lib/utils'; import {Box, HStack, Input, Pressable, SectionList, VStack} from 'native-base'; import React, {FC, useCallback, useEffect, useMemo, useState} from 'react'; import {SectionListRenderItem} from 'react-native'; @@ -141,6 +141,8 @@ export const SearchScreen = () => { navigate(ScreenNames.NewConversation, {addresses: participants}); }, [participants, navigate, goBack]); + const isValidAddress = useMemo(() => isAddress(searchText), [searchText]); + const items = useMemo(() => { const {filtered: filteredRecents, mapping: recentMapping} = recents.reduce<{ filtered: Contact[]; @@ -267,6 +269,17 @@ export const SearchScreen = () => { paddingY={'12px'} paddingX={'8px'} /> + {isValidAddress && ( + + + + {translate('valid_address')} + + + )} {participants.map(participant => {