Skip to content

Commit

Permalink
make a tweak to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 18, 2024
1 parent b11a74f commit 1c15b60
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions example/src/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,28 @@ function GroupListItem({
const [messages, setMessages] = useState<
DecodedMessage<SupportedContentTypes>[]
>([])
const lastMessage = messages?.[0]
const [getConsentState, setConsentState] = useState<string | undefined>()

const denyGroup = async () => {
await client?.contacts.deny([group.id])
group
.consentState()
.then(setConsentState)
.catch((e) => {
console.error('Error denying contact: ', e)
})
}

useEffect(() => {
group
?.sync()
.then(() => group.messages())
.then(setMessages)
.then(() => group.consentState())
.then((result) => {
setConsentState(result)
})
.catch((e) => {
console.error('Error fetching group messages: ', e)
})
Expand All @@ -128,16 +144,21 @@ function GroupListItem({
<Text style={{ fontWeight: 'bold' }}>
({messages?.length} messages)
</Text>
<Button
title="Deny"
onPress={denyGroup}
disabled={getConsentState === 'denied'}
/>
</View>
<View style={{ padding: 4 }}>
<Text style={{ fontWeight: 'bold', color: 'red' }}>
{getConsentState}
</Text>
<Text numberOfLines={1} ellipsizeMode="tail">
Fallback text
{lastMessage?.fallback}
</Text>
{/* <Text>{lastMessage?.senderAddress}:</Text>
<Text>{lastMessage?.senderAddress}:</Text>
<Text>{moment(lastMessage?.sent).fromNow()}</Text>
<Text style={{ fontWeight: 'bold', color: 'red' }}>
{getConsentState}
</Text> */}
</View>
</View>
</Pressable>
Expand Down

0 comments on commit 1c15b60

Please sign in to comment.