Fix leaving the room not always dismissing the room screen (#5089)
* Fix leaving the room not always dismissing the room screen Use the existing `RoomInfo` membership check to dismiss the room instead of using `RoomMembershipObserver`. * Restore `membershipObserver`, check Maestro still works * Improve the logic for the local membership change check * Remove redundant room id check
This commit is contained in:
committed by
GitHub
parent
308cbb4380
commit
28c09c1668
@@ -8,7 +8,9 @@
|
||||
package io.element.android.libraries.core.coroutine
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.runningFold
|
||||
|
||||
/**
|
||||
* Returns the first element of the flow that is an instance of [T], waiting for it if necessary.
|
||||
@@ -16,3 +18,14 @@ import kotlinx.coroutines.flow.first
|
||||
suspend inline fun <reified T> Flow<*>.firstInstanceOf(): T {
|
||||
return first { it is T } as T
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a flow that emits pairs of the previous and current values.
|
||||
* The first emission will be a pair of `null` and the first value emitted by the source flow.
|
||||
*/
|
||||
fun <T> Flow<T>.withPreviousValue(): Flow<Pair<T?, T>> {
|
||||
return runningFold(null) { prev: Pair<T?, T>?, current ->
|
||||
prev?.second to current
|
||||
}
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user