Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Who added me demo #370

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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 @@
<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
Loading