Skip to content

Commit

Permalink
return number of active groups synced from sync all groups function. …
Browse files Browse the repository at this point in the history
…possible fork fixes (#291)

Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Aug 26, 2024
1 parent 3bff0b1 commit 29bc28b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
14 changes: 12 additions & 2 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -912,29 +912,39 @@ class GroupTest {
runBlocking { alixClient.conversations.syncGroups() }
val alixGroup: Group = alixClient.findGroup(boGroup.id)!!
val alixGroup2: Group = alixClient.findGroup(boGroup2.id)!!
var numGroups: UInt?

assertEquals(alixGroup.messages().size, 0)
assertEquals(alixGroup2.messages().size, 0)

runBlocking {
boGroup.send("hi")
boGroup2.send("hi")
alixClient.conversations.syncAllGroups()
numGroups = alixClient.conversations.syncAllGroups()
}

assertEquals(alixGroup.messages().size, 1)
assertEquals(alixGroup2.messages().size, 1)
assertEquals(numGroups, 2u)

runBlocking {
boGroup2.removeMembers(listOf(alix.walletAddress))
boGroup.send("hi")
boGroup.send("hi")
boGroup2.send("hi")
boGroup2.send("hi")
alixClient.conversations.syncAllGroups()
numGroups = alixClient.conversations.syncAllGroups()
}

assertEquals(alixGroup.messages().size, 3)
assertEquals(alixGroup2.messages().size, 2)
// First syncAllGroups after remove includes the group you're removed from
assertEquals(numGroups, 2u)

runBlocking {
numGroups = alixClient.conversations.syncAllGroups()
}
// Next syncAllGroups will not include the inactive group
assertEquals(numGroups, 1u)
}
}
6 changes: 3 additions & 3 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: abe93739
Branch: main
Date: 2024-08-21 21:35:33 +0000
Version: 023fef7e
Branch: HEAD
Date: 2024-08-26 15:07:03 +0000
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ data class Conversations(
}

// Sync all existing local groups data from the network (Note: call syncGroups() first to get the latest list of groups)
suspend fun syncAllGroups() {
libXMTPConversations?.syncAllGroups()
suspend fun syncAllGroups(): UInt? {
return libXMTPConversations?.syncAllGroups()
}

suspend fun listGroups(
Expand Down
19 changes: 11 additions & 8 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ open class RustBuffer : Structure() {
// When dealing with these fields, make sure to call `toULong()`.
@JvmField
var capacity: Long = 0

@JvmField
var len: Long = 0

@JvmField
var data: Pointer? = null

Expand Down Expand Up @@ -135,6 +137,7 @@ class RustBufferByReference : ByReference(16) {
open class ForeignBytes : Structure() {
@JvmField
var len: Int = 0

@JvmField
var data: Pointer? = null

Expand Down Expand Up @@ -223,6 +226,7 @@ internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
internal open class UniffiRustCallStatus : Structure() {
@JvmField
var code: Byte = 0

@JvmField
var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()

Expand Down Expand Up @@ -1987,7 +1991,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_sync() != 9054.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_sync_all_groups() != 62850.toShort()) {
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_sync_all_groups() != 3433.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffigroup_add_admin() != 4600.toShort()) {
Expand Down Expand Up @@ -2656,7 +2660,7 @@ public interface FfiConversationsInterface {

suspend fun `sync`()

suspend fun `syncAllGroups`()
suspend fun `syncAllGroups`(): kotlin.UInt

companion object
}
Expand Down Expand Up @@ -2940,7 +2944,7 @@ open class FfiConversations : Disposable, AutoCloseable, FfiConversationsInterfa

@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `syncAllGroups`() {
override suspend fun `syncAllGroups`(): kotlin.UInt {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_fficonversations_sync_all_groups(
Expand All @@ -2949,22 +2953,21 @@ open class FfiConversations : Disposable, AutoCloseable, FfiConversationsInterfa
)
},
{ future, callback, continuation ->
UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_poll_void(
UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_poll_u32(
future,
callback,
continuation
)
},
{ future, continuation ->
UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_complete_void(
UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_complete_u32(
future,
continuation
)
},
{ future -> UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_free_void(future) },
{ future -> UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_free_u32(future) },
// lift function
{ Unit },

{ FfiConverterUInt.lift(it) },
// Error FFI converter
GenericException.ErrorHandler,
)
Expand Down
Binary file modified library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.

0 comments on commit 29bc28b

Please sign in to comment.