Commit 241aa1e0 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Implement markdown url resolve for loading single Issue and MergeRequest.

parent 56617a19
......@@ -10,7 +10,7 @@ data class Issue(
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("state") val state: IssueState,
@SerializedName("description") val description: String?,
@SerializedName("description") val description: String,
@SerializedName("author") val author: Author,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("project_id") val projectId: Long,
......
......@@ -22,7 +22,7 @@ data class MergeRequest(
@SerializedName("assignee") val assignee: User?,
@SerializedName("source_project_id") val sourceProjectId: Int,
@SerializedName("target_project_id") val targetProjectId: Int,
@SerializedName("description") val description: String?,
@SerializedName("description") val description: String,
@SerializedName("work_in_progress") val workInProgress: Boolean,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("merge_when_pipeline_succeeds") val mergeWhenPipelineSucceeds: Boolean,
......
......@@ -126,8 +126,19 @@ class IssueRepository @Inject constructor(
fun getIssue(
projectId: Long,
issueId: Long
) = api
.getIssue(projectId, issueId)
) = Single
.zip(
api.getProject(projectId),
api.getIssue(projectId, issueId),
BiFunction<Project, Issue, Issue> { project, issue ->
val resolved = markDownUrlResolver.resolve(issue.description, project)
if (resolved != issue.description) {
issue.copy(description = resolved)
} else {
issue
}
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
......
......@@ -140,8 +140,19 @@ class MergeRequestRepository @Inject constructor(
fun getMergeRequest(
projectId: Long,
mergeRequestId: Long
) = api
.getMergeRequest(projectId, mergeRequestId)
) = Single
.zip(
api.getProject(projectId),
api.getMergeRequest(projectId, mergeRequestId),
BiFunction<Project, MergeRequest, MergeRequest> { project, mr ->
val resolved = markDownUrlResolver.resolve(mr.description, project)
if (resolved != mr.description) {
mr.copy(description = resolved)
} else {
mr
}
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
......
......@@ -42,7 +42,7 @@ class IssueInfoPresenter @Inject constructor(
.getIssue(projectId, issueId)
.flatMap { issue ->
mdConverter
.markdownToSpannable(issue.description ?: "")
.markdownToSpannable(issue.description)
.map { Pair(issue, it) }
},
projectInteractor.getProject(projectId),
......
......@@ -42,7 +42,7 @@ class MergeRequestInfoPresenter @Inject constructor(
.getMergeRequest(projectId, mrId)
.flatMap { mr ->
mdConverter
.markdownToSpannable(mr.description ?: "")
.markdownToSpannable(mr.description)
.map { Pair(mr, it) }
},
projectInteractor.getProject(projectId),
......
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