Skip to content

Commit

Permalink
Merge pull request #258 from xmtp/cv/bump-android
Browse files Browse the repository at this point in the history
Bump android and isActive
  • Loading branch information
cameronvoell authored Feb 14, 2024
2 parents 2638c8a + 5accc01 commit ec5941f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 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 @@ -657,6 +657,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
12 changes: 11 additions & 1 deletion example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,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 @@ -483,6 +487,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
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,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 @@ -126,4 +126,8 @@ export class Group<
async removeMembers(addresses: string[]): Promise<void> {
return XMTP.removeGroupMembers(this.client.address, this.id, addresses)
}

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

0 comments on commit ec5941f

Please sign in to comment.