Commit 5a208ed6 authored by Maxim Myalkin's avatar Maxim Myalkin

Resolve discussion comments.

parent 6ee8904a
......@@ -80,7 +80,7 @@ object Screens {
data class MergeRequestFlow(
val projectId: Long,
val mrId: Long,
val targetAction: TargetAction?
val targetAction: TargetAction
) : SupportAppScreen() {
override fun getFragment() = MergeRequestFlowFragment.create(projectId, mrId, targetAction)
}
......
......@@ -46,7 +46,4 @@ annotation class WithErrorHandler
annotation class FilePath
@Qualifier
annotation class FileReference
@Qualifier
annotation class TargetEventAction
\ No newline at end of file
annotation class FileReference
\ No newline at end of file
......@@ -9,4 +9,6 @@ sealed class TargetAction : Serializable {
data class CommentedOn(val noteId: Long) : TargetAction()
object Undefined: TargetAction()
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ sealed class TargetHeader {
val targetId: Long,
val internal: TargetInternal?,
val badges: List<TargetBadge>,
val action: TargetAction?
val action: TargetAction
) : TargetHeader()
object Confidential : TargetHeader()
......
......@@ -268,12 +268,15 @@ class EventRepository @Inject constructor(
}
}
private fun getTargetAction(event: Event): TargetAction? =
private fun getTargetAction(event: Event): TargetAction =
when (event.actionName) {
EventAction.COMMENTED_ON -> {
event.note?.id?.let(TargetAction::CommentedOn)
event.note
?.id
?.let { TargetAction.CommentedOn(it) }
?: TargetAction.Undefined
}
else -> null
else -> TargetAction.Undefined
}
private fun getBody(event: Event, project: Project?) = when (event.targetType) {
......
......@@ -121,7 +121,7 @@ class IssueRepository @Inject constructor(
issue.id,
TargetInternal(issue.projectId, issue.iid),
badges,
null
TargetAction.Undefined
)
}
......
......@@ -132,7 +132,7 @@ class MergeRequestRepository @Inject constructor(
mr.id,
TargetInternal(mr.projectId, mr.iid),
badges,
null
TargetAction.Undefined
)
}
......
......@@ -87,7 +87,7 @@ class TodoRepository @Inject constructor(
target.id,
TargetInternal(target.projectId, target.iid),
badges,
null
TargetAction.Undefined
)
}
......
......@@ -7,7 +7,6 @@ import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.di.MergeRequestId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.di.TargetEventAction
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.app.target.TargetAction
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
......@@ -26,7 +25,7 @@ import javax.inject.Inject
class MergeRequestPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
@TargetEventAction targetActionWrapper: PrimitiveWrapper<TargetAction?>,
private val targetAction: TargetAction,
private val mrInteractor: MergeRequestInteractor,
private val projectInteractor: ProjectInteractor,
private val resourceManager: ResourceManager,
......@@ -36,7 +35,6 @@ class MergeRequestPresenter @Inject constructor(
private val projectId = projectIdWrapper.value
private val mrId = mrIdWrapper.value
private val targetAction = targetActionWrapper.value
override fun onFirstViewAttach() {
super.onFirstViewAttach()
......@@ -65,7 +63,7 @@ class MergeRequestPresenter @Inject constructor(
}
private fun selectActionTab() {
targetAction?.let(viewState::selectActionTab)
viewState.selectActionTab(targetAction)
}
fun onBackPressed() = flowRouter.exit()
......
......@@ -4,7 +4,6 @@ import com.arellomobile.mvp.InjectViewState
import ru.terrakok.gitlabclient.di.MergeRequestId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.di.TargetEventAction
import ru.terrakok.gitlabclient.entity.app.target.TargetAction
import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestInteractor
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
......@@ -20,7 +19,7 @@ import javax.inject.Inject
class MergeRequestNotesPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
@TargetEventAction targetActionWrapper: PrimitiveWrapper<TargetAction?>,
private val targetAction: TargetAction,
private val mrInteractor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
......@@ -28,7 +27,6 @@ class MergeRequestNotesPresenter @Inject constructor(
private val projectId = projectIdWrapper.value
private val mrId = mrIdWrapper.value
private val targetAction = targetActionWrapper.value
override fun onFirstViewAttach() {
super.onFirstViewAttach()
......@@ -46,7 +44,7 @@ class MergeRequestNotesPresenter @Inject constructor(
.toList()
.subscribe(
{ notes ->
val selectedNotePosition = targetAction?.let { it as? TargetAction.CommentedOn }
val selectedNotePosition = targetAction.let { it as? TargetAction.CommentedOn }
?.noteId
?.let { noteIdToSelect -> notes.indexOfFirst { it.note.id == noteIdToSelect } }
viewState.showNotes(notes, selectedNotePosition)
......
......@@ -5,7 +5,6 @@ import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.di.MergeRequestId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.di.TargetEventAction
import ru.terrakok.gitlabclient.entity.app.target.TargetAction
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.ui.global.FlowFragment
......@@ -16,7 +15,7 @@ class MergeRequestFlowFragment : FlowFragment() {
private val mrId by argument(ARG_MR_ID, 0L)
private val projectId by argument(ARG_PROJECT_ID, 0L)
private val targetAction by argument<TargetAction?>(ARG_TARGET_ACTION)
private val targetAction by argument<TargetAction>(ARG_TARGET_ACTION)
override fun installModules(scope: Scope) {
super.installModules(scope)
......@@ -29,9 +28,8 @@ class MergeRequestFlowFragment : FlowFragment() {
bind(PrimitiveWrapper::class.java)
.withName(MergeRequestId::class.java)
.toInstance(PrimitiveWrapper(mrId))
bind(PrimitiveWrapper::class.java)
.withName(TargetEventAction::class.java)
.toInstance(PrimitiveWrapper(targetAction))
bind(TargetAction::class.java)
.toInstance(targetAction)
}
}
)
......@@ -46,13 +44,13 @@ class MergeRequestFlowFragment : FlowFragment() {
fun create(
projectId: Long,
mrId: Long,
targetAction: TargetAction?
targetAction: TargetAction
) = MergeRequestFlowFragment().apply {
arguments = Bundle().apply {
putLong(ARG_PROJECT_ID, projectId)
putLong(ARG_MR_ID, mrId)
putSerializable(ARG_TARGET_ACTION, targetAction)
}
arguments = Bundle().apply {
putLong(ARG_PROJECT_ID, projectId)
putLong(ARG_MR_ID, mrId)
putSerializable(ARG_TARGET_ACTION, targetAction)
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment