File tree 3 files changed +12
-3
lines changed
example/src/main/java/org/xmtp/android/example
3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.emptyFlow
15
15
import kotlinx.coroutines.flow.flowOn
16
16
import kotlinx.coroutines.flow.mapLatest
17
17
import kotlinx.coroutines.launch
18
+ import kotlinx.coroutines.runBlocking
18
19
import org.xmtp.android.example.extension.flowWhileShared
19
20
import org.xmtp.android.example.extension.stateFlow
20
21
import org.xmtp.android.example.pushnotifications.PushNotificationTokenManager
@@ -70,7 +71,7 @@ class MainViewModel : ViewModel() {
70
71
71
72
@WorkerThread
72
73
private fun fetchMostRecentMessage (conversation : Conversation ): DecodedMessage ? {
73
- return conversation.messages(limit = 1 ).firstOrNull()
74
+ return runBlocking { conversation.messages(limit = 1 ).firstOrNull() }
74
75
}
75
76
76
77
@OptIn(ExperimentalCoroutinesApi ::class )
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.emptyFlow
15
15
import kotlinx.coroutines.flow.flowOn
16
16
import kotlinx.coroutines.flow.mapLatest
17
17
import kotlinx.coroutines.launch
18
+ import kotlinx.coroutines.runBlocking
18
19
import org.xmtp.android.example.ClientManager
19
20
import org.xmtp.android.example.extension.flowWhileShared
20
21
import org.xmtp.android.example.extension.stateFlow
@@ -77,7 +78,12 @@ class ConversationDetailViewModel(private val savedStateHandle: SavedStateHandle
77
78
stateFlow(viewModelScope, null ) { subscriptionCount ->
78
79
if (conversation == null ) {
79
80
conversation =
80
- ClientManager .client.fetchConversation(conversationTopic, includeGroups = false )
81
+ runBlocking {
82
+ ClientManager .client.fetchConversation(
83
+ conversationTopic,
84
+ includeGroups = false
85
+ )
86
+ }
81
87
}
82
88
if (conversation != null ) {
83
89
conversation!! .streamMessages()
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import com.google.firebase.messaging.RemoteMessage
14
14
import kotlinx.coroutines.Dispatchers
15
15
import kotlinx.coroutines.GlobalScope
16
16
import kotlinx.coroutines.launch
17
+ import kotlinx.coroutines.runBlocking
17
18
import org.xmtp.android.example.ClientManager
18
19
import org.xmtp.android.example.R
19
20
import org.xmtp.android.example.conversation.ConversationDetailActivity
@@ -56,7 +57,8 @@ class PushNotificationsService : FirebaseMessagingService() {
56
57
GlobalScope .launch(Dispatchers .Main ) {
57
58
ClientManager .createClient(keysData, applicationContext)
58
59
}
59
- val conversation = ClientManager .client.fetchConversation(topic, includeGroups = true )
60
+ val conversation =
61
+ runBlocking { ClientManager .client.fetchConversation(topic, includeGroups = true ) }
60
62
if (conversation == null ) {
61
63
Log .e(TAG , " No keys or conversation persisted" )
62
64
return
You can’t perform that action at this time.
0 commit comments