Use context parameter for the parentNode
This commit is contained in:
parent
02dc71c4c3
commit
f174084942
138 changed files with 450 additions and 375 deletions
|
|
@ -16,7 +16,8 @@ import io.element.android.libraries.di.SessionScope
|
|||
|
||||
@ContributesBinding(SessionScope::class)
|
||||
class DefaultMessagesEntryPoint : MessagesEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext, params: MessagesEntryPoint.Params, callback: MessagesEntryPoint.Callback): Node {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext, params: MessagesEntryPoint.Params, callback: MessagesEntryPoint.Callback): Node {
|
||||
return parentNode.createNode<MessagesFlowNode>(buildContext, listOf(params, callback))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,6 @@ class MessagesFlowNode(
|
|||
}
|
||||
}
|
||||
mediaViewerEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = params,
|
||||
callback = callback
|
||||
|
|
@ -337,7 +336,7 @@ class MessagesFlowNode(
|
|||
}
|
||||
is NavTarget.LocationViewer -> {
|
||||
val inputs = ShowLocationEntryPoint.Inputs(navTarget.location, navTarget.description)
|
||||
showLocationEntryPoint.createNode(this, buildContext, inputs)
|
||||
showLocationEntryPoint.createNode(buildContext, inputs)
|
||||
}
|
||||
is NavTarget.EventDebugInfo -> {
|
||||
val inputs = EventDebugInfoNode.Inputs(navTarget.eventId, navTarget.debugInfo)
|
||||
|
|
@ -359,7 +358,6 @@ class MessagesFlowNode(
|
|||
}
|
||||
}
|
||||
forwardEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = params,
|
||||
callback = callback,
|
||||
|
|
@ -371,14 +369,12 @@ class MessagesFlowNode(
|
|||
}
|
||||
is NavTarget.SendLocation -> {
|
||||
sendLocationEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
timelineMode = navTarget.timelineMode,
|
||||
)
|
||||
}
|
||||
is NavTarget.CreatePoll -> {
|
||||
createPollEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = CreatePollEntryPoint.Params(
|
||||
timelineMode = navTarget.timelineMode,
|
||||
|
|
@ -388,7 +384,6 @@ class MessagesFlowNode(
|
|||
}
|
||||
is NavTarget.EditPoll -> {
|
||||
createPollEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = CreatePollEntryPoint.Params(
|
||||
timelineMode = navTarget.timelineMode,
|
||||
|
|
@ -428,7 +423,7 @@ class MessagesFlowNode(
|
|||
createNode<PinnedMessagesListNode>(buildContext, plugins = listOf(callback))
|
||||
}
|
||||
NavTarget.KnockRequestsList -> {
|
||||
knockRequestsListEntryPoint.createNode(this, buildContext)
|
||||
knockRequestsListEntryPoint.createNode(buildContext)
|
||||
}
|
||||
is NavTarget.Thread -> {
|
||||
val inputs = ThreadedMessagesNode.Inputs(
|
||||
|
|
|
|||
|
|
@ -66,18 +66,19 @@ class DefaultMessagesEntryPointTest {
|
|||
roomListService = FakeRoomListService(),
|
||||
sessionId = A_SESSION_ID,
|
||||
sendLocationEntryPoint = object : SendLocationEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
timelineMode: Timeline.Mode,
|
||||
) = lambdaError()
|
||||
},
|
||||
showLocationEntryPoint = object : ShowLocationEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext, inputs: ShowLocationEntryPoint.Inputs) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext, inputs: ShowLocationEntryPoint.Inputs) = lambdaError()
|
||||
},
|
||||
createPollEntryPoint = object : CreatePollEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: Params,
|
||||
) = lambdaError()
|
||||
|
|
@ -99,16 +100,16 @@ class DefaultMessagesEntryPointTest {
|
|||
},
|
||||
mediaViewerEntryPoint = object : MediaViewerEntryPoint {
|
||||
override fun createParamsForAvatar(filename: String, avatarUrl: String) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: MediaViewerEntryPoint.Params,
|
||||
callback: MediaViewerEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
forwardEntryPoint = object : ForwardEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: ForwardEntryPoint.Params,
|
||||
callback: ForwardEntryPoint.Callback,
|
||||
|
|
@ -129,7 +130,8 @@ class DefaultMessagesEntryPointTest {
|
|||
pinnedEventsTimelineProvider = createPinnedEventsTimelineProvider(),
|
||||
timelineController = createTimelineController(),
|
||||
knockRequestsListEntryPoint = object : KnockRequestsListEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
dateFormatter = FakeDateFormatter(),
|
||||
coroutineDispatchers = testCoroutineDispatchers(),
|
||||
|
|
@ -144,12 +146,13 @@ class DefaultMessagesEntryPointTest {
|
|||
}
|
||||
val initialTarget = MessagesEntryPoint.InitialTarget.Messages(focusedEventId = AN_EVENT_ID)
|
||||
val params = MessagesEntryPoint.Params(initialTarget)
|
||||
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(MessagesFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(MessagesEntryPoint.Params(initialTarget))
|
||||
assertThat(result.plugins).contains(callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue