Skip to content

Commit 76bfcc7

Browse files
committed
remove all the streams work and move to another PR
1 parent 2f4abdc commit 76bfcc7

File tree

6 files changed

+5
-140
lines changed

6 files changed

+5
-140
lines changed

library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt

-37
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package org.xmtp.android.library
22

33
import androidx.test.ext.junit.runners.AndroidJUnit4
44
import androidx.test.platform.app.InstrumentationRegistry
5-
import app.cash.turbine.test
6-
import kotlinx.coroutines.ExperimentalCoroutinesApi
75
import kotlinx.coroutines.runBlocking
86
import org.junit.Assert.assertEquals
97
import org.junit.Before
@@ -18,7 +16,6 @@ import org.xmtp.android.library.messages.PrivateKey
1816
import org.xmtp.android.library.messages.PrivateKeyBuilder
1917
import org.xmtp.android.library.messages.walletAddress
2018

21-
@OptIn(ExperimentalCoroutinesApi::class)
2219
@RunWith(AndroidJUnit4::class)
2320
class GroupTest {
2421
lateinit var fakeApiClient: FakeApiClient
@@ -177,38 +174,4 @@ class GroupTest {
177174
assertEquals(ReactionAction.Added, content?.action)
178175
assertEquals(ReactionSchema.Unicode, content?.schema)
179176
}
180-
181-
@Test
182-
fun testCanStreamGroupMessages() = kotlinx.coroutines.test.runTest {
183-
val group = boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
184-
185-
group.streamMessages().test {
186-
group.send("hi")
187-
assertEquals("hi", awaitItem().body)
188-
awaitComplete()
189-
}
190-
}
191-
192-
@Test
193-
fun testCanStreamGroups() = kotlinx.coroutines.test.runTest {
194-
boClient.conversations.streamGroups().test {
195-
val conversation =
196-
boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
197-
conversation.send(content = "hi")
198-
assertEquals("hi", awaitItem().messages().first().body)
199-
awaitComplete()
200-
}
201-
}
202-
203-
@Test
204-
fun testCanStreamGroupsAndConversations() = kotlinx.coroutines.test.runTest {
205-
boClient.conversations.stream(includeGroups = true).test {
206-
val group =
207-
boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
208-
val conversation =
209-
boClient.conversations.newConversation(alix.walletAddress.lowercase())
210-
assertEquals("hi", awaitItem().messages().first().body)
211-
awaitComplete()
212-
}
213-
}
214177
}

library/src/main/java/org/xmtp/android/library/Conversation.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ sealed class Conversation {
318318
return when (this) {
319319
is V1 -> conversationV1.streamMessages()
320320
is V2 -> conversationV2.streamMessages()
321-
is Group -> group.streamMessages()
321+
is Group -> throw XMTPException("Coming follow up PR")
322322
}
323323
}
324324

325325
fun streamDecryptedMessages(): Flow<DecryptedMessage> {
326326
return when (this) {
327327
is V1 -> conversationV1.streamDecryptedMessages()
328328
is V2 -> conversationV2.streamDecryptedMessages()
329-
is Group -> group.streamDecryptedMessages()
329+
is Group -> throw XMTPException("Coming follow up PR")
330330
}
331331
}
332332

library/src/main/java/org/xmtp/android/library/Conversations.kt

+3-34
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package org.xmtp.android.library
33
import android.util.Log
44
import io.grpc.StatusException
55
import kotlinx.coroutines.CancellationException
6-
import kotlinx.coroutines.coroutineScope
76
import kotlinx.coroutines.flow.Flow
87
import kotlinx.coroutines.flow.MutableStateFlow
98
import kotlinx.coroutines.flow.flow
10-
import kotlinx.coroutines.launch
119
import kotlinx.coroutines.runBlocking
1210
import org.xmtp.android.library.GRPCApiClient.Companion.makeQueryRequest
1311
import org.xmtp.android.library.GRPCApiClient.Companion.makeSubscribeRequest
@@ -36,7 +34,6 @@ import org.xmtp.proto.message.contents.Contact
3634
import org.xmtp.proto.message.contents.Invitation
3735
import uniffi.xmtpv3.FfiConversations
3836
import uniffi.xmtpv3.FfiListConversationsOptions
39-
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.GroupEmitter
4037
import java.util.Date
4138
import kotlin.time.Duration.Companion.nanoseconds
4239
import kotlin.time.DurationUnit
@@ -93,8 +90,8 @@ data class Conversations(
9390
if (accountAddresses.isEmpty()) {
9491
throw XMTPException("Cannot start an empty group chat.")
9592
}
96-
if (accountAddresses.size == 1 && accountAddresses.first()
97-
.lowercase() == client.address.lowercase()
93+
if (accountAddresses.size == 1 &&
94+
accountAddresses.first().lowercase() == client.address.lowercase()
9895
) {
9996
throw XMTPException("Recipient is sender")
10097
}
@@ -476,21 +473,7 @@ data class Conversations(
476473
* of the information of those conversations according to the topics
477474
* @return Stream of data information for the conversations
478475
*/
479-
fun stream(includeGroups: Boolean = false): Flow<Conversation> = flow {
480-
if (includeGroups) {
481-
val groupEmitter = GroupEmitter()
482-
483-
coroutineScope {
484-
launch {
485-
groupEmitter.groups.collect { group ->
486-
emit(Conversation.Group(Group(client, group)))
487-
}
488-
}
489-
}
490-
491-
libXMTPConversations?.stream(groupEmitter.callback)
492-
}
493-
476+
fun stream(): Flow<Conversation> = flow {
494477
val streamedConversationTopics: MutableSet<String> = mutableSetOf()
495478
client.subscribeTopic(
496479
listOf(Topic.userIntro(client.address), Topic.userInvite(client.address)),
@@ -514,20 +497,6 @@ data class Conversations(
514497
}
515498
}
516499

517-
fun streamGroups(): Flow<Group> = flow {
518-
val groupEmitter = GroupEmitter()
519-
520-
coroutineScope {
521-
launch {
522-
groupEmitter.groups.collect { group ->
523-
emit(Group(client, group))
524-
}
525-
}
526-
}
527-
528-
libXMTPConversations?.stream(groupEmitter.callback)
529-
}
530-
531500
/**
532501
* Get the stream of all messages of the current [Client]
533502
* @return Flow object of [DecodedMessage] that represents all the messages of the

library/src/main/java/org/xmtp/android/library/Group.kt

-33
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package org.xmtp.android.library
22

3-
import kotlinx.coroutines.coroutineScope
4-
import kotlinx.coroutines.flow.Flow
5-
import kotlinx.coroutines.flow.flow
6-
import kotlinx.coroutines.launch
73
import kotlinx.coroutines.runBlocking
84
import org.xmtp.android.library.codecs.ContentCodec
95
import org.xmtp.android.library.codecs.EncodedContent
106
import org.xmtp.android.library.codecs.compress
117
import org.xmtp.android.library.libxmtp.Message
12-
import org.xmtp.android.library.libxmtp.MessageEmitter
138
import org.xmtp.android.library.messages.DecryptedMessage
149
import org.xmtp.android.library.messages.PagingInfoSortDirection
1510
import org.xmtp.proto.message.api.v1.MessageApiOuterClass
@@ -128,34 +123,6 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) {
128123
)
129124
}
130125

131-
fun streamMessages(): Flow<DecodedMessage> = flow {
132-
val messageEmitter = MessageEmitter()
133-
134-
coroutineScope {
135-
launch {
136-
messageEmitter.messages.collect { message ->
137-
emit(Message(client, message).decode())
138-
}
139-
}
140-
}
141-
142-
libXMTPGroup.stream(messageEmitter.callback)
143-
}
144-
145-
fun streamDecryptedMessages(): Flow<DecryptedMessage> = flow {
146-
val messageEmitter = MessageEmitter()
147-
148-
coroutineScope {
149-
launch {
150-
messageEmitter.messages.collect { message ->
151-
emit(decrypt(Message(client, message)))
152-
}
153-
}
154-
}
155-
156-
libXMTPGroup.stream(messageEmitter.callback)
157-
}
158-
159126
fun addMembers(addresses: List<String>) {
160127
runBlocking { libXMTPGroup.addMembers(addresses) }
161128
}

library/src/main/java/org/xmtp/android/library/libxmtp/GroupEmitter.kt

-17
This file was deleted.

library/src/main/java/org/xmtp/android/library/libxmtp/MessageEmitter.kt

-17
This file was deleted.

0 commit comments

Comments
 (0)