[gh/gl] Fix review-in-editor not starting (IJPL-186195, IJPL-187199, IJPL-181783)

#IJPL-187199 Fixed
#IJPL-186195 Fixed

Cause of which is a threading exception on loading `.getContent()`


(cherry picked from commit eec980bbaf107e2caa4f08c5150e74b773e0593b)

IJ-CR-163488

GitOrigin-RevId: 263439b1b91f620222c5d27739485231164173fd
This commit is contained in:
Chris Lemaire
2025-05-20 12:02:06 +02:00
committed by intellij-monorepo-bot
parent a96d82325e
commit b99f825790
2 changed files with 9 additions and 4 deletions

View File

@@ -18,7 +18,9 @@ import com.intellij.platform.util.coroutines.childScope
import git4idea.changes.GitTextFilePatchWithHistory
import git4idea.changes.createVcsChange
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.withContext
import org.jetbrains.plugins.github.api.data.GHUser
import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestReviewThread
import org.jetbrains.plugins.github.api.data.pullrequest.isVisible
@@ -65,9 +67,9 @@ internal class GHPRReviewFileEditorViewModelImpl(
private val diffData: GitTextFilePatchWithHistory,
private val threadsVms: GHPRThreadsViewModels,
private val discussionsViewOption: StateFlow<DiscussionsViewOption>,
private val showDiff: (change: RefComparisonChange, lineIdx: Int?) -> Unit
private val showDiff: (change: RefComparisonChange, lineIdx: Int?) -> Unit,
) : GHPRReviewFileEditorViewModel {
private val cs = parentCs.childScope(javaClass.name)
private val cs = parentCs.childScope(javaClass.name, Dispatchers.Default)
override val iconProvider: GHAvatarIconsProvider = dataContext.avatarIconsProvider
override val currentUser: GHUser = dataContext.securityService.currentUser
@@ -83,7 +85,8 @@ internal class GHPRReviewFileEditorViewModelImpl(
}?.onFailure {
LOG.warn("Couldn't load head content for $change", it)
}
}.stateIn(cs, SharingStarted.Lazily, ComputedResult.loading())
}.flowOn(Dispatchers.IO)
.stateIn(cs, SharingStarted.Lazily, ComputedResult.loading())
override val changedRanges: List<Range> = diffData.patch.hunks.withoutContext().toList()

View File

@@ -23,6 +23,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.withContext
import org.jetbrains.plugins.gitlab.api.dto.GitLabUserDTO
import org.jetbrains.plugins.gitlab.mergerequest.data.GitLabMergeRequest
import org.jetbrains.plugins.gitlab.mergerequest.data.GitLabMergeRequestNewDiscussionPosition
@@ -76,7 +77,8 @@ internal class GitLabMergeRequestEditorReviewFileViewModelImpl(
}.let {
emit(it)
}
}.stateIn(cs, SharingStarted.Lazily, ComputedResult.loading())
}.flowOn(Dispatchers.IO)
.stateIn(cs, SharingStarted.Lazily, ComputedResult.loading())
override val changedRanges: List<Range> = diffData.patch.hunks.withoutContext().toList()