Skip to content

Commit

Permalink
Merge branch 'beta' into cv/conversation-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Feb 14, 2024
2 parents 53240fa + ac99485 commit b9b6d36
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.facebook.react:react-native:0.71.3'
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"
implementation "org.xmtp:android:0.7.11"
implementation "org.xmtp:android:0.7.12"
// xmtp-android local testing setup below (comment org.xmtp:android above)
// implementation files('<PATH TO XMTP-ANDROID>/xmtp-android/library/build/outputs/aar/library-debug.aar')
// implementation 'com.google.crypto.tink:tink-android:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,17 @@ class XMTPModule : Module() {
runBlocking { group?.removeMembers(peerAddresses) }
}

Function("isGroupActive") { clientAddress: String, id: String ->
logV("isGroupActive")
val client = clients[clientAddress] ?: throw XMTPException("No client")
if (client.libXMTPClient == null) {
throw XMTPException("Create client with enableAlphaMLS true in order to create a group")
}
val group = findGroup(clientAddress, id)

group?.isActive()
}

Function("subscribeToConversations") { clientAddress: String ->
logV("subscribeToConversations")
subscribeToConversations(clientAddress = clientAddress)
Expand Down
14 changes: 12 additions & 2 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,11 @@ test('can remove members from a group', async () => {
)
}

await aliceGroup.removeMembers([bobClient.address])
if (!camGroups[0].isActive()) {
throw new Error('cams group should be active')
}

await aliceGroup.removeMembers([camClient.address])
await aliceGroup.sync()
const aliceGroupMembers = await aliceGroup.memberAddresses()
if (aliceGroupMembers.length !== 2) {
Expand All @@ -484,6 +488,12 @@ test('can remove members from a group', async () => {
// }

await camGroups[0].sync()
await camClient.conversations.syncGroups()

if (camGroups[0].isActive()) {
throw new Error('cams group should not be active')
}

const camGroupMembers = await camGroups[0].memberAddresses()
if (camGroupMembers.length !== 2) {
throw new Error('num group members should be 2')
Expand Down Expand Up @@ -1372,7 +1382,7 @@ test('register and use custom content types', async () => {
assert(
typeof messageContent === 'object' &&
'topNumber' in messageContent &&
messageContent.topNumber.bottomNumber === 1,
messageContent.topNumber.bottomNumber === 12,
'did not get content properly: ' + JSON.stringify(messageContent)
)

Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ export function preCreateIdentityCallbackCompleted() {
XMTPModule.preCreateIdentityCallbackCompleted()
}

export function isGroupActive(clientAddress: string, id: string): boolean {
return XMTPModule.isGroupActive(clientAddress, id)
}

export const emitter = new EventEmitter(XMTPModule ?? NativeModulesProxy.XMTP)

export * from './XMTP.types'
Expand Down
4 changes: 4 additions & 0 deletions src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,8 @@ export class Group<
isGroup(): boolean {
return true
}

Check warning on line 141 in src/lib/Group.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
isActive(): boolean {
return XMTP.isGroupActive(this.client.address, this.id)
}
}

0 comments on commit b9b6d36

Please sign in to comment.