Ensure a Callback and only one is provided in the Plugin. Also reduce boilerplate code in Nodes.
This commit is contained in:
parent
2e8785b36b
commit
be03c50aaf
76 changed files with 374 additions and 741 deletions
|
|
@ -23,6 +23,7 @@ import dev.zacsweers.metro.AssistedInject
|
|||
import io.element.android.annotations.ContributesNode
|
||||
import io.element.android.features.share.api.ShareEntryPoint
|
||||
import io.element.android.libraries.architecture.NodeInputs
|
||||
import io.element.android.libraries.architecture.callback
|
||||
import io.element.android.libraries.architecture.inputs
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
|
|
@ -52,7 +53,7 @@ class ShareNode(
|
|||
|
||||
private val inputs = inputs<Inputs>()
|
||||
private val presenter = presenterFactory.create(inputs.intent)
|
||||
private val callbacks = plugins.filterIsInstance<ShareEntryPoint.Callback>()
|
||||
private val callback: ShareEntryPoint.Callback = callback()
|
||||
|
||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
val callback = object : RoomSelectEntryPoint.Callback {
|
||||
|
|
@ -61,7 +62,7 @@ class ShareNode(
|
|||
}
|
||||
|
||||
override fun onCancel() {
|
||||
onShareDone(emptyList())
|
||||
callback.onDone(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,12 +83,8 @@ class ShareNode(
|
|||
val state = presenter.present()
|
||||
ShareView(
|
||||
state = state,
|
||||
onShareSuccess = ::onShareDone,
|
||||
onShareSuccess = callback::onDone,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onShareDone(roomIds: List<RoomId>) {
|
||||
callbacks.forEach { it.onDone(roomIds) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue