Skip to content

Commit

Permalink
add the UI code to show who added me
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 18, 2024
1 parent 716c0ac commit b284b3e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions example/src/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Client,
useXmtp,
DecodedMessage,
addedByAddress,

Check warning on line 17 in example/src/HomeScreen.tsx

View workflow job for this annotation

GitHub Actions / lint

'addedByAddress' is defined but never used
} from 'xmtp-react-native-sdk'
import { Group } from 'xmtp-react-native-sdk/lib/Group'

Expand Down Expand Up @@ -99,12 +100,24 @@ function GroupListItem({
const [messages, setMessages] = useState<
DecodedMessage<SupportedContentTypes>[]
>([])
const [getAddByAddressState, setAddByAddressState] = useState<
string | undefined
>()

useEffect(() => {
group
?.sync()
.then(() => group.messages())
.then(setMessages)
.then(() => group.addedByAddress())
.then((result) => client?.contacts.isDenied(result))
.then((result) => {
if (result) {
setAddByAddressState('The user that added you is blocked')
} else {
setAddByAddressState('')
}
})
.catch((e) => {
console.error('Error fetching group messages: ', e)
})
Expand Down Expand Up @@ -133,6 +146,9 @@ function GroupListItem({
<Text numberOfLines={1} ellipsizeMode="tail">
Fallback text
</Text>
<Text style={{ fontWeight: 'bold', color: 'red' }}>
{getAddByAddressState}
</Text>
{/* <Text>{lastMessage?.senderAddress}:</Text>
<Text>{moment(lastMessage?.sent).fromNow()}</Text>
<Text style={{ fontWeight: 'bold', color: 'red' }}>
Expand Down

0 comments on commit b284b3e

Please sign in to comment.