diff --git a/example/src/ConversationCreateScreen.tsx b/example/src/ConversationCreateScreen.tsx index bec2470c4..6973bb6ac 100644 --- a/example/src/ConversationCreateScreen.tsx +++ b/example/src/ConversationCreateScreen.tsx @@ -21,12 +21,13 @@ export default function ConversationCreateScreen({ return } if (groupsEnabled) { - const canMessage = (await client.canGroupMessage([toAddress]))[0] + const toAddresses = toAddress.split(',') + const canMessage = await client.canGroupMessage(toAddresses) if (!canMessage) { setAlert(`${toAddress} cannot be added to a group conversation yet`) return } - const group = await client.conversations.newGroup([toAddress]) + const group = await client.conversations.newGroup(toAddresses) navigation.navigate('group', { id: group.id }) } else { const canMessage = await client.canMessage(toAddress) diff --git a/example/src/GroupScreen.tsx b/example/src/GroupScreen.tsx index ca98f827f..4c4909427 100644 --- a/example/src/GroupScreen.tsx +++ b/example/src/GroupScreen.tsx @@ -131,7 +131,7 @@ export default function GroupScreen({ ) return ( - + []>( ['xmtp', 'groups', client?.address], - async () => (await client?.conversations.listGroups()) || [], + async () => { + await client?.conversations.syncGroups() + return (await client?.conversations.listGroups()) || [] + }, { enabled: !!client, } @@ -128,6 +131,8 @@ export function useGroupMessages({ ['xmtp', 'groupMessages', client?.address, group?.id], async () => { await group!.sync() + const messages = await group!.messages() + console.log('messages', messages) return group!.messages() }, { diff --git a/src/index.ts b/src/index.ts index 5e57721a7..7fd84eb7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -217,7 +217,7 @@ export async function canMessage( export async function canGroupMessage( clientAddress: string, peerAddresses: string[] -): Promise { +): Promise { return await XMTPModule.canGroupMessage(clientAddress, peerAddresses) } diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 40ea91338..001c9372e 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -199,7 +199,7 @@ export class Client< * @param {string[]} addresses - The addresses of the peers to check for messaging eligibility. * @returns {Promise} A Promise resolving to true for peers where group messaging is allowed, and false otherwise. */ - async canGroupMessage(addresses: string[]): Promise { + async canGroupMessage(addresses: string[]): Promise { return await XMTPModule.canGroupMessage(this.address, addresses) }