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

@ -16,8 +16,8 @@ import io.element.android.libraries.architecture.createNode
@ContributesBinding(AppScope::class)
class DefaultPreferencesEntryPoint : PreferencesEntryPoint {
context(parentNode: Node)
override fun createNode(
parentNode: Node,
buildContext: BuildContext,
params: PreferencesEntryPoint.Params,
callback: PreferencesEntryPoint.Callback,

View file

@ -216,6 +216,7 @@ class PreferencesFlowNode(
}
NavTarget.TroubleshootNotifications -> {
notificationTroubleShootEntryPoint.createNode(
parentNode = this,
buildContext = buildContext,
callback = object : NotificationTroubleShootEntryPoint.Callback {
override fun onDone() {
@ -234,6 +235,7 @@ class PreferencesFlowNode(
}
NavTarget.PushHistory -> {
pushHistoryEntryPoint.createNode(
parentNode = this,
buildContext = buildContext,
callback = object : PushHistoryEntryPoint.Callback {
override fun onDone() {
@ -268,6 +270,7 @@ class PreferencesFlowNode(
}
NavTarget.LockScreenSettings -> {
lockScreenEntryPoint.createNode(
parentNode = this,
buildContext = buildContext,
navTarget = LockScreenEntryPoint.Target.Settings,
callback = object : LockScreenEntryPoint.Callback {
@ -287,15 +290,16 @@ class PreferencesFlowNode(
}
}
logoutEntryPoint.createNode(
parentNode = this,
buildContext = buildContext,
callback = callBack,
)
}
is NavTarget.OssLicenses -> {
openSourceLicensesEntryPoint.createNode(buildContext)
openSourceLicensesEntryPoint.createNode(this, buildContext)
}
NavTarget.AccountDeactivation -> {
accountDeactivationEntryPoint.createNode(buildContext)
accountDeactivationEntryPoint.createNode(this, buildContext)
}
}
}

View file

@ -57,13 +57,12 @@ class DefaultPreferencesEntryPointTest {
val params = PreferencesEntryPoint.Params(
initialElement = PreferencesEntryPoint.InitialTarget.NotificationSettings,
)
val result = with(parentNode) {
entryPoint.createNode(
buildContext = BuildContext.root(null),
params = params,
callback = callback,
)
}
val result = entryPoint.createNode(
parentNode = parentNode,
buildContext = BuildContext.root(null),
params = params,
callback = callback,
)
assertThat(result).isInstanceOf(PreferencesFlowNode::class.java)
assertThat(result.plugins).contains(params)
assertThat(result.plugins).contains(callback)