Commit 0162df81 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Resolve discussion comments.

parent 1523bf33
......@@ -29,7 +29,7 @@ class IssueRepository @Inject constructor(
private val markDownUrlResolver: MarkDownUrlResolver
) {
private val defaultPageSize = defaultPageSizeWrapper.value
private var issueSharedSingle: Single<Issue>? = null
private val issueSharedSingles = mutableMapOf<Pair<Long, Long>, Single<Issue>>()
fun getMyIssues(
scope: IssueScope? = null,
......@@ -131,8 +131,9 @@ class IssueRepository @Inject constructor(
issueId: Long
) = Single
.defer {
if (issueSharedSingle == null) {
issueSharedSingle = Single
val key = Pair(projectId, issueId)
if (!issueSharedSingles.contains(key)) {
issueSharedSingles[key] = Single
.zip(
api.getProject(projectId),
api.getIssue(projectId, issueId),
......@@ -149,7 +150,7 @@ class IssueRepository @Inject constructor(
.share()
.singleOrError()
}
issueSharedSingle
issueSharedSingles[key]
}
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
......
......@@ -26,7 +26,7 @@ class MergeRequestRepository @Inject constructor(
private val markDownUrlResolver: MarkDownUrlResolver
) {
private val defaultPageSize = defaultPageSizeWrapper.value
private var mergeRequestSharedSingle: Single<MergeRequest>? = null
private val mergeRequestSharedSingles = mutableMapOf<Pair<Long, Long>, Single<MergeRequest>>()
fun getMyMergeRequests(
state: MergeRequestState? = null,
......@@ -142,8 +142,9 @@ class MergeRequestRepository @Inject constructor(
mergeRequestId: Long
) = Single
.defer {
if (mergeRequestSharedSingle == null) {
mergeRequestSharedSingle = Single
val key = Pair(projectId, mergeRequestId)
if (!mergeRequestSharedSingles.contains(key)) {
mergeRequestSharedSingles[key] = Single
.zip(
api.getProject(projectId),
api.getMergeRequest(projectId, mergeRequestId),
......@@ -160,7 +161,7 @@ class MergeRequestRepository @Inject constructor(
.share()
.singleOrError()
}
mergeRequestSharedSingle
mergeRequestSharedSingles[key]
}
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
......
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