Remove NodeBuilder to ensure that Params and Callback are always provided.
This commit is contained in:
parent
be03c50aaf
commit
02dc71c4c3
115 changed files with 954 additions and 1174 deletions
|
|
@ -9,7 +9,6 @@ package io.element.android.features.startchat.impl
|
|||
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import io.element.android.features.startchat.api.StartChatEntryPoint
|
||||
|
|
@ -17,18 +16,7 @@ import io.element.android.libraries.architecture.createNode
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultStartChatEntryPoint : StartChatEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): StartChatEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
return object : StartChatEntryPoint.NodeBuilder {
|
||||
override fun callback(callback: StartChatEntryPoint.Callback): StartChatEntryPoint.NodeBuilder {
|
||||
plugins += callback
|
||||
return this
|
||||
}
|
||||
|
||||
override fun build(): Node {
|
||||
return parentNode.createNode<StartChatFlowNode>(buildContext, plugins)
|
||||
}
|
||||
}
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext, callback: StartChatEntryPoint.Callback): Node {
|
||||
return parentNode.createNode<StartChatFlowNode>(buildContext, listOf(callback))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,9 +79,11 @@ class StartChatFlowNode(
|
|||
navigator.onRoomCreated(roomId.toRoomIdOrAlias(), emptyList())
|
||||
}
|
||||
}
|
||||
createRoomEntryPoint.nodeBuilder(parentNode = this, buildContext = buildContext)
|
||||
.callback(callback)
|
||||
.build()
|
||||
createRoomEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = callback,
|
||||
)
|
||||
}
|
||||
NavTarget.JoinByAddress -> {
|
||||
createNode<JoinRoomByAddressNode>(buildContext = buildContext, plugins = listOf(navigator))
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ class DefaultStartChatEntryPointTest {
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
createRoomEntryPoint = object : CreateRoomEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: CreateRoomEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -43,9 +47,11 @@ class DefaultStartChatEntryPointTest {
|
|||
override fun onRoomCreated(roomIdOrAlias: RoomIdOrAlias, serverNames: List<String>) = lambdaError()
|
||||
override fun navigateToRoomDirectory() = lambdaError()
|
||||
}
|
||||
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||
.callback(callback)
|
||||
.build()
|
||||
val result = entryPoint.createNode(
|
||||
parentNode = parentNode,
|
||||
buildContext = BuildContext.root(null),
|
||||
callback = callback,
|
||||
)
|
||||
assertThat(result).isInstanceOf(StartChatFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(callback)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue