Dagger: makes sure to not remove an active component when navigating
This commit is contained in:
parent
ba44ff32c1
commit
3ba219c975
4 changed files with 16 additions and 13 deletions
|
|
@ -68,13 +68,13 @@ class MainNode(
|
|||
}
|
||||
|
||||
private val roomFlowNodeCallback = object : RoomFlowNode.LifecycleCallback {
|
||||
override fun onFlowCreated(room: MatrixRoom) {
|
||||
override fun onFlowCreated(owner: String, room: MatrixRoom) {
|
||||
val component = bindings<RoomComponent.ParentBindings>().roomComponentBuilder().room(room).build()
|
||||
mainDaggerComponentOwner.addComponent(room.roomId.value, component)
|
||||
mainDaggerComponentOwner.addComponent(owner, component)
|
||||
}
|
||||
|
||||
override fun onFlowReleased(room: MatrixRoom) {
|
||||
mainDaggerComponentOwner.removeComponent(room.roomId.value)
|
||||
override fun onFlowReleased(owner: String, room: MatrixRoom) {
|
||||
mainDaggerComponentOwner.removeComponent(owner)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class MainDaggerComponentsOwner @Inject constructor(@ApplicationContext context:
|
|||
daggerComponents.remove(identifier)
|
||||
}
|
||||
|
||||
/**
|
||||
* We expose the dagger components in the opposite order they arrived.
|
||||
* So we pick the most recent component when searching with the [io.element.android.libraries.architecture.bindings] methods.
|
||||
*/
|
||||
override val daggerComponent: Any
|
||||
get() = daggerComponents.values.reversed()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue