Use context parameter for the parentNode
This commit is contained in:
parent
566515ca88
commit
05c5f3c914
138 changed files with 450 additions and 375 deletions
|
|
@ -18,8 +18,8 @@ import io.element.android.libraries.architecture.createNode
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultRoomDetailsEntryPoint : RoomDetailsEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: RoomDetailsEntryPoint.Params,
|
||||
callback: RoomDetailsEntryPoint.Callback,
|
||||
|
|
|
|||
|
|
@ -308,14 +308,13 @@ class RoomDetailsFlowNode(
|
|||
avatarUrl = navTarget.avatarUrl,
|
||||
)
|
||||
mediaViewerEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
}
|
||||
is NavTarget.PollHistory -> {
|
||||
pollHistoryEntryPoint.createNode(this, buildContext)
|
||||
pollHistoryEntryPoint.createNode(buildContext)
|
||||
}
|
||||
is NavTarget.MediaGallery -> {
|
||||
val callback = object : MediaGalleryEntryPoint.Callback {
|
||||
|
|
@ -336,7 +335,6 @@ class RoomDetailsFlowNode(
|
|||
}
|
||||
}
|
||||
mediaGalleryEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = callback,
|
||||
)
|
||||
|
|
@ -367,14 +365,13 @@ class RoomDetailsFlowNode(
|
|||
}
|
||||
}
|
||||
return messagesEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
}
|
||||
NavTarget.KnockRequestsList -> {
|
||||
knockRequestsListEntryPoint.createNode(this, buildContext)
|
||||
knockRequestsListEntryPoint.createNode(buildContext)
|
||||
}
|
||||
NavTarget.SecurityAndPrivacy -> {
|
||||
createNode<SecurityAndPrivacyFlowNode>(buildContext)
|
||||
|
|
@ -385,7 +382,6 @@ class RoomDetailsFlowNode(
|
|||
verificationRequest = VerificationRequest.Outgoing.User(userId = navTarget.userId)
|
||||
)
|
||||
outgoingVerificationEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
params = params,
|
||||
callback = object : OutgoingVerificationEntryPoint.Callback {
|
||||
|
|
@ -404,12 +400,11 @@ class RoomDetailsFlowNode(
|
|||
)
|
||||
}
|
||||
is NavTarget.ReportRoom -> {
|
||||
reportRoomEntryPoint.createNode(this, buildContext, room.roomId)
|
||||
reportRoomEntryPoint.createNode(buildContext, room.roomId)
|
||||
}
|
||||
|
||||
is NavTarget.SelectNewOwnersWhenLeaving -> {
|
||||
changeRoomMemberRolesEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
room = room,
|
||||
listType = ChangeRoomMemberRolesListType.SelectNewOwnersWhenLeaving,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ class RolesAndPermissionsFlowNode(
|
|||
}
|
||||
is NavTarget.AdminList -> {
|
||||
changeRoomMemberRolesEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
room = joinedRoom,
|
||||
listType = ChangeRoomMemberRolesListType.Admins,
|
||||
|
|
@ -110,7 +109,6 @@ class RolesAndPermissionsFlowNode(
|
|||
}
|
||||
is NavTarget.ModeratorList -> {
|
||||
changeRoomMemberRolesEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
room = joinedRoom,
|
||||
listType = ChangeRoomMemberRolesListType.Moderators,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ class DefaultRoomDetailsEntryPointTest {
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
pollHistoryEntryPoint = object : PollHistoryEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
elementCallEntryPoint = object : ElementCallEntryPoint {
|
||||
override fun startCall(callType: CallType) = lambdaError()
|
||||
|
|
@ -73,46 +74,49 @@ class DefaultRoomDetailsEntryPointTest {
|
|||
room = FakeJoinedRoom(),
|
||||
analyticsService = FakeAnalyticsService(),
|
||||
messagesEntryPoint = object : MessagesEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: MessagesEntryPoint.Params,
|
||||
callback: MessagesEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
knockRequestsListEntryPoint = object : KnockRequestsListEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
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()
|
||||
},
|
||||
mediaGalleryEntryPoint = object : MediaGalleryEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: MediaGalleryEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
outgoingVerificationEntryPoint = object : OutgoingVerificationEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: OutgoingVerificationEntryPoint.Params,
|
||||
callback: OutgoingVerificationEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
reportRoomEntryPoint = object : ReportRoomEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext, roomId: RoomId) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext, roomId: RoomId) = lambdaError()
|
||||
},
|
||||
changeRoomMemberRolesEntryPoint = object : ChangeRoomMemberRolesEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
room: JoinedRoom,
|
||||
listType: ChangeRoomMemberRolesListType,
|
||||
|
|
@ -129,12 +133,13 @@ class DefaultRoomDetailsEntryPointTest {
|
|||
val params = RoomDetailsEntryPoint.Params(
|
||||
initialElement = RoomDetailsEntryPoint.InitialTarget.RoomDetails,
|
||||
)
|
||||
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(RoomDetailsFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(params)
|
||||
assertThat(result.plugins).contains(callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue