When handling incoming share, reuse existing room screen if possible (#6001)
This commit is contained in:
committed by
GitHub
parent
31b7c8e585
commit
a234eb3e29
@@ -516,9 +516,18 @@ class LoggedInFlowNode(
|
||||
params = ShareEntryPoint.Params(intent = navTarget.intent),
|
||||
callback = object : ShareEntryPoint.Callback {
|
||||
override fun onDone(roomIds: List<RoomId>) {
|
||||
// Remove the incoming share screen
|
||||
backstack.pop()
|
||||
|
||||
// Navigate to the room if the text/media was shared to a single one
|
||||
roomIds.singleOrNull()?.let { roomId ->
|
||||
backstack.push(NavTarget.Room(roomId.toRoomIdOrAlias()))
|
||||
sessionCoroutineScope.launch {
|
||||
// Wait until the incoming share screen is removed
|
||||
backstack.elements.first { it.lastOrNull()?.key?.navTarget !is NavTarget.IncomingShare }
|
||||
|
||||
// Then attach the room
|
||||
attachRoom(roomId.toRoomIdOrAlias(), clearBackstack = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -643,8 +652,22 @@ private class AttachRoomOperation(
|
||||
targetState = ACTIVE,
|
||||
operation = this
|
||||
)
|
||||
} else {
|
||||
val existingRoomElement = elements.find {
|
||||
val roomNavTarget = it.key.navTarget as? LoggedInFlowNode.NavTarget.Room
|
||||
roomNavTarget?.roomIdOrAlias == roomTarget.roomIdOrAlias
|
||||
}
|
||||
if (existingRoomElement != null) {
|
||||
elements.mapNotNull { element ->
|
||||
if (element == existingRoomElement) {
|
||||
null
|
||||
} else {
|
||||
element.transitionTo(STASHED, this)
|
||||
}
|
||||
} + existingRoomElement.transitionTo(ACTIVE, this)
|
||||
} else {
|
||||
Push<LoggedInFlowNode.NavTarget>(roomTarget).invoke(elements)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user