mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
When handling incoming share, reuse existing room screen if possible (#6001)
This commit is contained in:
committed by
GitHub
parent
e311a719e1
commit
983c012b79
@@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user