Remove NodeBuilder to ensure that Params and Callback are always provided.

This commit is contained in:
Benoit Marty 2025-10-30 11:37:59 +01:00 committed by Benoit Marty
parent be03c50aaf
commit 02dc71c4c3
115 changed files with 954 additions and 1174 deletions

View file

@ -77,11 +77,12 @@ class BugReportFlowNode(
val params = ViewFolderEntryPoint.Params(
rootPath = navTarget.rootPath,
)
viewFolderEntryPoint
.nodeBuilder(this, buildContext)
.params(params)
.callback(callback)
.build()
viewFolderEntryPoint.createNode(
parentNode = this,
buildContext = buildContext,
params = params,
callback = callback,
)
}
}
}

View file

@ -9,7 +9,6 @@ package io.element.android.features.rageshake.impl.bugreport
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.rageshake.api.bugreport.BugReportEntryPoint
@ -17,18 +16,7 @@ import io.element.android.libraries.architecture.createNode
@ContributesBinding(AppScope::class)
class DefaultBugReportEntryPoint : BugReportEntryPoint {
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): BugReportEntryPoint.NodeBuilder {
val plugins = ArrayList<Plugin>()
return object : BugReportEntryPoint.NodeBuilder {
override fun callback(callback: BugReportEntryPoint.Callback): BugReportEntryPoint.NodeBuilder {
plugins += callback
return this
}
override fun build(): Node {
return parentNode.createNode<BugReportFlowNode>(buildContext, plugins)
}
}
override fun createNode(parentNode: Node, buildContext: BuildContext, callback: BugReportEntryPoint.Callback): Node {
return parentNode.createNode<BugReportFlowNode>(buildContext, listOf(callback))
}
}

View file

@ -35,16 +35,23 @@ class DefaultBugReportEntryPointTest {
buildContext = buildContext,
plugins = plugins,
viewFolderEntryPoint = object : ViewFolderEntryPoint {
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
params: ViewFolderEntryPoint.Params,
callback: ViewFolderEntryPoint.Callback,
) = lambdaError()
},
)
}
val callback = object : BugReportEntryPoint.Callback {
override fun onDone() = 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(BugReportFlowNode::class.java)
assertThat(result.plugins).contains(callback)
}