diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorViewModel.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorViewModel.kt index d01af4452783..6cfce8663b53 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorViewModel.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/editor/GHPRReviewFileEditorViewModel.kt @@ -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, - 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 = diffData.patch.hunks.withoutContext().toList() diff --git a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewFileViewModel.kt b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewFileViewModel.kt index d71102c679b9..55f171d6cf8c 100644 --- a/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewFileViewModel.kt +++ b/plugins/gitlab/gitlab-core/src/org/jetbrains/plugins/gitlab/mergerequest/ui/editor/GitLabMergeRequestEditorReviewFileViewModel.kt @@ -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 = diffData.patch.hunks.withoutContext().toList()