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