Skip to content

Commit

Permalink
revert back to previous way of loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 26, 2023
1 parent 6d41133 commit ee94075
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions library/src/main/java/org/xmtp/android/library/Contacts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum class ConsentState {
BLOCKED,
UNKNOWN
}

data class ConsentListEntry(
val value: String,
val entryType: EntryType,
Expand Down Expand Up @@ -68,18 +69,11 @@ class ConsentList(val client: Client) {
}

preferences.reversed().iterator().forEach { preference ->
when(preference.messageTypeCase) {
PrivatePreferencesAction.MessageTypeCase.ALLOW -> {
preference.allow.walletAddressesList.forEach {
consentList.allow(it)
}
}
PrivatePreferencesAction.MessageTypeCase.BLOCK -> {
preference.block.walletAddressesList.forEach {
consentList.block(it)
}
}
else -> Unit
preference.allow?.walletAddressesList?.forEach { address ->
consentList.allow(address)
}
preference.block?.walletAddressesList?.forEach { address ->
consentList.block(address)
}
}

Expand All @@ -90,8 +84,14 @@ class ConsentList(val client: Client) {
fun publish(entry: ConsentListEntry) {
val payload = PrivatePreferencesAction.newBuilder().also {
when (entry.consentType) {
ConsentState.ALLOWED -> it.setAllow(PrivatePreferencesAction.Allow.newBuilder().addWalletAddresses(entry.value))
ConsentState.BLOCKED -> it.setBlock(PrivatePreferencesAction.Block.newBuilder().addWalletAddresses(entry.value))
ConsentState.ALLOWED -> it.setAllow(
PrivatePreferencesAction.Allow.newBuilder().addWalletAddresses(entry.value)
)

ConsentState.BLOCKED -> it.setBlock(
PrivatePreferencesAction.Block.newBuilder().addWalletAddresses(entry.value)
)

ConsentState.UNKNOWN -> it.clearMessageType()
}
}.build()
Expand Down

0 comments on commit ee94075

Please sign in to comment.