Merge branch 'develop' into feature/bma/fixSendQueueCrash
This commit is contained in:
@@ -48,9 +48,11 @@ import io.element.android.libraries.matrix.api.core.RoomIdOrAlias
|
||||
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
|
||||
import io.element.android.libraries.matrix.api.getRoomInfoFlow
|
||||
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
|
||||
import io.element.android.libraries.matrix.api.room.RoomMembershipObserver
|
||||
import io.element.android.libraries.matrix.api.room.alias.ResolvedRoomAlias
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -67,6 +69,7 @@ class RoomFlowNode @AssistedInject constructor(
|
||||
private val joinRoomEntryPoint: JoinRoomEntryPoint,
|
||||
private val roomAliasResolverEntryPoint: RoomAliasResolverEntryPoint,
|
||||
private val networkMonitor: NetworkMonitor,
|
||||
private val membershipObserver: RoomMembershipObserver,
|
||||
) : BaseFlowNode<RoomFlowNode.NavTarget>(
|
||||
backstack = BackStack(
|
||||
initialElement = NavTarget.Loading,
|
||||
@@ -145,10 +148,6 @@ class RoomFlowNode @AssistedInject constructor(
|
||||
backstack.newRoot(NavTarget.JoinedRoom(roomId))
|
||||
}
|
||||
}
|
||||
CurrentUserMembership.LEFT -> {
|
||||
// Left the room, navigate out of this flow
|
||||
navigateUp()
|
||||
}
|
||||
else -> {
|
||||
// Was invited or the room is not known, display the join room screen
|
||||
backstack.newRoot(
|
||||
@@ -161,6 +160,15 @@ class RoomFlowNode @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
}.launchIn(lifecycleScope)
|
||||
|
||||
// If the user leaves the room from this client, close the room flow.
|
||||
lifecycleScope.launch {
|
||||
membershipObserver.updates
|
||||
.first { it.roomId == roomId && !it.isUserInRoom }
|
||||
.run {
|
||||
navigateUp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
|
||||
Reference in New Issue
Block a user