Remove context(parentNode: Node) and provide the parent Node as a parameter.

This commit is contained in:
Benoit Marty 2025-10-31 12:04:57 +01:00
parent f1822c5afd
commit 07b6148035
161 changed files with 668 additions and 436 deletions

View file

@ -18,8 +18,8 @@ import io.element.android.libraries.matrix.api.timeline.Timeline
* Allows a user to share a location message within a room.
*/
interface SendLocationEntryPoint : FeatureEntryPoint {
context(parentNode: Node)
fun createNode(
parentNode: Node,
buildContext: BuildContext,
timelineMode: Timeline.Mode,
): Node

View file

@ -13,8 +13,14 @@ import io.element.android.libraries.architecture.FeatureEntryPoint
import io.element.android.libraries.architecture.NodeInputs
interface ShowLocationEntryPoint : FeatureEntryPoint {
data class Inputs(val location: Location, val description: String?) : NodeInputs
data class Inputs(
val location: Location,
val description: String?,
) : NodeInputs
context(parentNode: Node)
fun createNode(buildContext: BuildContext, inputs: Inputs): Node
fun createNode(
parentNode: Node,
buildContext: BuildContext,
inputs: Inputs,
): Node
}

View file

@ -17,8 +17,8 @@ import io.element.android.libraries.matrix.api.timeline.Timeline
@ContributesBinding(AppScope::class)
class DefaultSendLocationEntryPoint : SendLocationEntryPoint {
context(parentNode: Node)
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
timelineMode: Timeline.Mode,
): Node {

View file

@ -16,8 +16,11 @@ import io.element.android.libraries.architecture.createNode
@ContributesBinding(AppScope::class)
class DefaultShowLocationEntryPoint : ShowLocationEntryPoint {
context(parentNode: Node)
override fun createNode(buildContext: BuildContext, inputs: ShowLocationEntryPoint.Inputs): Node {
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
inputs: ShowLocationEntryPoint.Inputs,
): Node {
return parentNode.createNode<ShowLocationNode>(buildContext, listOf(inputs))
}
}

View file

@ -47,12 +47,11 @@ class DefaultSendLocationEntryPointTest {
)
}
val timelineMode = Timeline.Mode.Live
val result = with(parentNode) {
entryPoint.createNode(
buildContext = BuildContext.root(null),
timelineMode = timelineMode,
)
}
val result = entryPoint.createNode(
parentNode = parentNode,
buildContext = BuildContext.root(null),
timelineMode = timelineMode,
)
assertThat(result).isInstanceOf(SendLocationNode::class.java)
assertThat(result.plugins).contains(SendLocationNode.Inputs(timelineMode))
}

View file

@ -47,12 +47,11 @@ class DefaultShowLocationEntryPointTest {
location = Location(37.4219983, -122.084, 10f),
description = "My location",
)
val result = with(parentNode) {
entryPoint.createNode(
buildContext = BuildContext.root(null),
inputs = inputs,
)
}
val result = entryPoint.createNode(
parentNode = parentNode,
buildContext = BuildContext.root(null),
inputs = inputs,
)
assertThat(result).isInstanceOf(ShowLocationNode::class.java)
assertThat(result.plugins).contains(inputs)
}

View file

@ -14,8 +14,8 @@ import io.element.android.libraries.matrix.api.timeline.Timeline
import io.element.android.tests.testutils.lambda.lambdaError
class FakeSendLocationEntryPoint : SendLocationEntryPoint {
context(parentNode: Node)
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
timelineMode: Timeline.Mode,
): Node = lambdaError()

View file

@ -13,8 +13,8 @@ import io.element.android.features.location.api.ShowLocationEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakeShowLocationEntryPoint : ShowLocationEntryPoint {
context(parentNode: Node)
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
inputs: ShowLocationEntryPoint.Inputs,
): Node = lambdaError()