Skip to content

Commit

Permalink
getting closer on these streams
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 16, 2024
1 parent b2326c1 commit edfa2b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class V3ClientTest {
conversation.send("hi")
dm.send("hi")
}
Thread.sleep(1000)
Thread.sleep(2500)
assertEquals(3, allMessages.size)
job.cancel()
}
Expand Down
18 changes: 9 additions & 9 deletions library/src/main/java/org/xmtp/android/library/Conversations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ data class Conversations(
if (conversation.groupMetadata().conversationType() == "dm") {
launch {
val dm = Dm(client, conversation)
val matchingConversations = list().filter {
client.inboxIdFromAddress(it.peerAddress)?.lowercase() ==
val matchingConversations = conversationsByTopic.filter {
client.inboxIdFromAddress(it.value.peerAddress)?.lowercase() ==
dm.peerInboxId().lowercase()
}

// Only send the DM if no V2 DM exists
if (matchingConversations.none { it.version == Conversation.Version.V2 }) {
if (matchingConversations.none { it.value.version == Conversation.Version.V2 }) {
trySend(Conversation.Dm(dm)).isSuccess
}
}
Expand Down Expand Up @@ -704,13 +704,13 @@ data class Conversations(
when (conversation?.version) {
Conversation.Version.DM -> {
launch {
val matchingConversations = list().filter {
client.inboxIdFromAddress(it.peerAddress)?.lowercase() ==
val matchingConversations = conversationsByTopic.filter {
client.inboxIdFromAddress(it.value.peerAddress)?.lowercase() ==
conversation.peerAddress
}

// If there is no V2 conversation, send the decoded message
if (matchingConversations.none { it.version == Conversation.Version.V2 }) {
if (matchingConversations.none { it.value.version == Conversation.Version.V2 }) {
decodedMessage?.let { trySend(it).isSuccess }
}
}
Expand Down Expand Up @@ -738,13 +738,13 @@ data class Conversations(
when (conversation?.version) {
Conversation.Version.DM -> {
launch {
val matchingConversations = list().filter {
client.inboxIdFromAddress(it.peerAddress)?.lowercase() ==
val matchingConversations = conversationsByTopic.filter {
client.inboxIdFromAddress(it.value.peerAddress)?.lowercase() ==
conversation.peerAddress
}

// If there is no V2 conversation, send the decoded message
if (matchingConversations.none { it.version == Conversation.Version.V2 }) {
if (matchingConversations.none { it.value.version == Conversation.Version.V2 }) {
decryptedMessage?.let { trySend(it).isSuccess }
}
}
Expand Down

0 comments on commit edfa2b6

Please sign in to comment.