mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Use context parameter for the parentNode
This commit is contained in:
committed by
Benoit Marty
parent
02dc71c4c3
commit
f174084942
+2
-1
@@ -31,7 +31,8 @@ interface PreferencesEntryPoint : FeatureEntryPoint {
|
||||
|
||||
data class Params(val initialElement: InitialTarget) : NodeInputs
|
||||
|
||||
fun createNode(parentNode: Node, buildContext: BuildContext, params: Params, callback: Callback): Node
|
||||
context(parentNode: Node)
|
||||
fun createNode(buildContext: BuildContext, params: Params, callback: Callback): Node
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun navigateToAddAccount()
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
+4
-8
@@ -216,7 +216,6 @@ class PreferencesFlowNode(
|
||||
}
|
||||
NavTarget.TroubleshootNotifications -> {
|
||||
notificationTroubleShootEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = object : NotificationTroubleShootEntryPoint.Callback {
|
||||
override fun onDone() {
|
||||
@@ -235,9 +234,8 @@ class PreferencesFlowNode(
|
||||
}
|
||||
NavTarget.PushHistory -> {
|
||||
pushHistoryEntryPoint.createNode(
|
||||
this,
|
||||
buildContext,
|
||||
object : PushHistoryEntryPoint.Callback {
|
||||
buildContext = buildContext,
|
||||
callback = object : PushHistoryEntryPoint.Callback {
|
||||
override fun onDone() {
|
||||
if (backstack.canPop()) {
|
||||
backstack.pop()
|
||||
@@ -270,7 +268,6 @@ class PreferencesFlowNode(
|
||||
}
|
||||
NavTarget.LockScreenSettings -> {
|
||||
lockScreenEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
navTarget = LockScreenEntryPoint.Target.Settings,
|
||||
callback = object : LockScreenEntryPoint.Callback {
|
||||
@@ -290,16 +287,15 @@ class PreferencesFlowNode(
|
||||
}
|
||||
}
|
||||
logoutEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = callBack,
|
||||
)
|
||||
}
|
||||
is NavTarget.OssLicenses -> {
|
||||
openSourceLicensesEntryPoint.createNode(this, buildContext)
|
||||
openSourceLicensesEntryPoint.createNode(buildContext)
|
||||
}
|
||||
NavTarget.AccountDeactivation -> {
|
||||
accountDeactivationEntryPoint.createNode(this, buildContext)
|
||||
accountDeactivationEntryPoint.createNode(buildContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-12
@@ -42,8 +42,8 @@ class DefaultPreferencesEntryPointTest {
|
||||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
lockScreenEntryPoint = object : LockScreenEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
navTarget: LockScreenEntryPoint.Target,
|
||||
callback: LockScreenEntryPoint.Callback,
|
||||
@@ -52,31 +52,33 @@ class DefaultPreferencesEntryPointTest {
|
||||
override fun pinUnlockIntent(context: Context) = lambdaError()
|
||||
},
|
||||
notificationTroubleShootEntryPoint = object : NotificationTroubleShootEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: NotificationTroubleShootEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
pushHistoryEntryPoint = object : PushHistoryEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: PushHistoryEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
logoutEntryPoint = object : LogoutEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: LogoutEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
openSourceLicensesEntryPoint = object : OpenSourceLicensesEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
accountDeactivationEntryPoint = object : AccountDeactivationEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -90,12 +92,13 @@ class DefaultPreferencesEntryPointTest {
|
||||
val params = PreferencesEntryPoint.Params(
|
||||
initialElement = PreferencesEntryPoint.InitialTarget.NotificationSettings,
|
||||
)
|
||||
val result = entryPoint.createNode(
|
||||
parentNode = parentNode,
|
||||
buildContext = BuildContext.root(null),
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
val result = with(parentNode) {
|
||||
entryPoint.createNode(
|
||||
buildContext = BuildContext.root(null),
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
}
|
||||
assertThat(result).isInstanceOf(PreferencesFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(params)
|
||||
assertThat(result.plugins).contains(callback)
|
||||
|
||||
Reference in New Issue
Block a user