When handling incoming share, reuse existing room screen if possible (#6001)
This commit is contained in:
parent
31b7c8e585
commit
a234eb3e29
1 changed files with 25 additions and 2 deletions
|
|
@ -516,9 +516,18 @@ class LoggedInFlowNode(
|
||||||
params = ShareEntryPoint.Params(intent = navTarget.intent),
|
params = ShareEntryPoint.Params(intent = navTarget.intent),
|
||||||
callback = object : ShareEntryPoint.Callback {
|
callback = object : ShareEntryPoint.Callback {
|
||||||
override fun onDone(roomIds: List<RoomId>) {
|
override fun onDone(roomIds: List<RoomId>) {
|
||||||
|
// Remove the incoming share screen
|
||||||
backstack.pop()
|
backstack.pop()
|
||||||
|
|
||||||
|
// Navigate to the room if the text/media was shared to a single one
|
||||||
roomIds.singleOrNull()?.let { roomId ->
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -644,7 +653,21 @@ private class AttachRoomOperation(
|
||||||
operation = this
|
operation = this
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Push<LoggedInFlowNode.NavTarget>(roomTarget).invoke(elements)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue