using combine instead of merge for syncing until the event appears
This commit is contained in:
parent
a8218b7e66
commit
50e12c8c54
|
@ -1,6 +1,5 @@
|
|||
package app.dapk.st.directory
|
||||
|
||||
import android.util.Log
|
||||
import app.dapk.st.matrix.common.CredentialsStore
|
||||
import app.dapk.st.matrix.common.RoomId
|
||||
import app.dapk.st.matrix.common.RoomMember
|
||||
|
@ -40,7 +39,6 @@ class DirectoryUseCase(
|
|||
roomStore.observeUnreadCountById(),
|
||||
syncService.events()
|
||||
) { userId, overviewState, localEchos, unread, events ->
|
||||
Log.e("!!!", "got states")
|
||||
overviewState.mergeWithLocalEchos(localEchos, userId).map { roomOverview ->
|
||||
RoomFoo(
|
||||
overview = roomOverview,
|
||||
|
|
|
@ -10,10 +10,9 @@ import app.dapk.st.matrix.common.RoomId
|
|||
import com.google.firebase.messaging.FirebaseMessagingService
|
||||
import com.google.firebase.messaging.RemoteMessage
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.merge
|
||||
|
||||
private var previousJob: Job? = null
|
||||
|
||||
|
@ -70,8 +69,7 @@ class PushAndroidService : FirebaseMessagingService() {
|
|||
|
||||
private suspend fun waitForEvent(timeout: Long, eventId: EventId): EventId? {
|
||||
return withTimeoutOrNull(timeout) {
|
||||
val syncFlow = module.syncService().startSyncing().map { it as EventId }
|
||||
merge(syncFlow, module.syncService().observeEvent(eventId))
|
||||
combine(module.syncService().startSyncing(), module.syncService().observeEvent(eventId)) { _, event -> event }
|
||||
.firstOrNull {
|
||||
it == eventId
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue