Skip to content

Commit

Permalink
get the batch consent setup for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 20, 2024
1 parent d5a0b37 commit 773800f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions library/src/main/java/org/xmtp/android/library/Contacts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.xmtp.android.library.messages.Topic
import org.xmtp.android.library.messages.walletAddress
import org.xmtp.proto.message.api.v1.MessageApiOuterClass
import org.xmtp.proto.message.contents.PrivatePreferences.PrivatePreferencesAction
import uniffi.xmtpv3.FfiConsent
import uniffi.xmtpv3.FfiConsentEntityType
import uniffi.xmtpv3.FfiConsentState
import java.util.Date
Expand Down Expand Up @@ -89,6 +90,14 @@ data class ConsentListEntry(
}
}

fun toFfiConsent(): FfiConsent {
return FfiConsent(
EntryType.toFfiConsentEntityType(entryType),
ConsentState.toFfiConsentState(consentType),
value
)
}

val key: String
get() = "${entryType.name}-$value"
}
Expand Down Expand Up @@ -230,13 +239,7 @@ class ConsentList(
}

suspend fun setV3ConsentState(entries: List<ConsentListEntry>) {
entries.iterator().forEach {
client.v3Client?.setConsentState(
ConsentState.toFfiConsentState(it.consentType),
EntryType.toFfiConsentEntityType(it.entryType),
it.value
)
}
client.v3Client?.setConsentStates(entries.map { it.toFfiConsent() })
}

fun allow(address: String): ConsentListEntry {
Expand Down

0 comments on commit 773800f

Please sign in to comment.