Skip to content

Commit 59c9bad

Browse files
committed
Restore null case
1 parent 00009d0 commit 59c9bad

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

appnav/src/main/kotlin/io/element/android/appnav/room/RoomFlowNode.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import io.element.android.libraries.architecture.BaseFlowNode
4747
import io.element.android.libraries.architecture.NodeInputs
4848
import io.element.android.libraries.architecture.createNode
4949
import io.element.android.libraries.architecture.inputs
50+
import io.element.android.libraries.core.bool.orFalse
5051
import io.element.android.libraries.di.SessionScope
5152
import io.element.android.libraries.matrix.api.MatrixClient
5253
import io.element.android.libraries.matrix.api.core.RoomAlias
@@ -55,7 +56,6 @@ import io.element.android.libraries.matrix.api.core.RoomIdOrAlias
5556
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
5657
import kotlinx.coroutines.flow.combine
5758
import kotlinx.coroutines.flow.distinctUntilChanged
58-
import kotlinx.coroutines.flow.filterNotNull
5959
import kotlinx.coroutines.flow.launchIn
6060
import kotlinx.coroutines.flow.map
6161
import kotlinx.coroutines.launch
@@ -123,12 +123,10 @@ class RoomFlowNode @AssistedInject constructor(
123123
private fun subscribeToRoomInfoFlow(roomId: RoomId) {
124124
val roomInfoFlow = client.getRoomInfoFlow(
125125
roomId = roomId
126-
)
127-
.map { it.getOrNull() }
128-
.filterNotNull()
126+
).map { it.getOrNull() }
129127

130-
val isSpaceFlow = roomInfoFlow.map { it.isSpace }.distinctUntilChanged()
131-
val currentMembershipFlow = roomInfoFlow.map { it.currentUserMembership }.distinctUntilChanged()
128+
val isSpaceFlow = roomInfoFlow.map { it?.isSpace.orFalse() }.distinctUntilChanged()
129+
val currentMembershipFlow = roomInfoFlow.map { it?.currentUserMembership }.distinctUntilChanged()
132130
combine(currentMembershipFlow, isSpaceFlow) { membership, isSpace ->
133131
Timber.d("Room membership: $membership")
134132
when (membership) {
@@ -147,8 +145,8 @@ class RoomFlowNode @AssistedInject constructor(
147145
// Left the room, navigate out of this flow
148146
navigateUp()
149147
}
150-
CurrentUserMembership.INVITED -> {
151-
// Was invited, display the join room screen
148+
else -> {
149+
// Was invited or the room is not known, display the join room screen
152150
backstack.newRoot(NavTarget.JoinRoom(roomId))
153151
}
154152
}

0 commit comments

Comments
 (0)