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 5197154f54
commit 566515ca88
115 changed files with 954 additions and 1174 deletions

View file

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

View file

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

View file

@ -36,9 +36,11 @@ class DefaultNotificationTroubleShootEntryPointTest {
override fun onDone() = lambdaError()
override fun navigateToBlockedUsers() = 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(TroubleshootNotificationsNode::class.java)
assertThat(result.plugins).contains(callback)
}

View file

@ -48,9 +48,11 @@ class DefaultPushHistoryEntryPointTest {
override fun onDone() = lambdaError()
override fun navigateToEvent(roomId: RoomId, eventId: EventId) = 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(PushHistoryNode::class.java)
assertThat(result.plugins).contains(callback)
}