mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
[github] Make changesComputationState an internal-API function
(cherry picked from commit ddf495030801429d9bbcc8977468e0129e4787eb) (cherry picked from commit 8553adf7d89bc793125e90a7fbf60d91beaec11d) IJ-CR-148445 GitOrigin-RevId: 49a1e4ea9971ff0a3d871eacbe1cad9516a0f7c1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9b6b287618
commit
401e8f31e5
@@ -7,6 +7,7 @@ import com.intellij.collaboration.util.ComputedResult
|
|||||||
import com.intellij.openapi.diff.impl.patch.FilePatch
|
import com.intellij.openapi.diff.impl.patch.FilePatch
|
||||||
import git4idea.changes.GitBranchComparisonResult
|
import git4idea.changes.GitBranchComparisonResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import org.jetbrains.plugins.github.api.data.GHCommit
|
import org.jetbrains.plugins.github.api.data.GHCommit
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
@@ -28,5 +29,6 @@ interface GHPRChangesDataProvider {
|
|||||||
fun loadCommitsFromApi(): CompletableFuture<List<GHCommit>>
|
fun loadCommitsFromApi(): CompletableFuture<List<GHCommit>>
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val GHPRChangesDataProvider.changesComputationState: Flow<ComputedResult<GitBranchComparisonResult>>
|
@ApiStatus.Internal
|
||||||
get() = computationStateFlow(changesNeedReloadSignal.withInitial(Unit)) { loadChanges() }
|
fun GHPRChangesDataProvider.changesComputationState(): Flow<ComputedResult<GitBranchComparisonResult>> =
|
||||||
|
computationStateFlow(changesNeedReloadSignal.withInitial(Unit)) { loadChanges() }
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ internal class GHPRReviewInEditorViewModelImpl(
|
|||||||
private val repository = dataContext.repositoryDataService.repositoryMapping.gitRepository
|
private val repository = dataContext.repositoryDataService.repositoryMapping.gitRepository
|
||||||
|
|
||||||
private val changesComputationState =
|
private val changesComputationState =
|
||||||
dataProvider.changesData.changesComputationState.onEach {
|
dataProvider.changesData.changesComputationState().onEach {
|
||||||
it.onFailure {
|
it.onFailure {
|
||||||
LOG.warn("Couldn't load changes for PR ${dataProvider.id.number}", it)
|
LOG.warn("Couldn't load changes for PR ${dataProvider.id.number}", it)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ internal class GHPRReviewNewCommentEditorViewModelImpl(
|
|||||||
private val settings = GithubPullRequestsProjectUISettings.getInstance(project)
|
private val settings = GithubPullRequestsProjectUISettings.getInstance(project)
|
||||||
private val reviewDataProvider = dataProvider.reviewData
|
private val reviewDataProvider = dataProvider.reviewData
|
||||||
private val changesState: StateFlow<ComputedResult<GitBranchComparisonResult>> =
|
private val changesState: StateFlow<ComputedResult<GitBranchComparisonResult>> =
|
||||||
dataProvider.changesData.changesComputationState.stateInNow(cs, ComputedResult.loading())
|
dataProvider.changesData.changesComputationState().stateInNow(cs, ComputedResult.loading())
|
||||||
|
|
||||||
private val pendingReviewState: StateFlow<ComputedResult<GHPullRequestPendingReview?>> =
|
private val pendingReviewState: StateFlow<ComputedResult<GHPullRequestPendingReview?>> =
|
||||||
reviewDataProvider.pendingReviewComputationFlow.stateInNow(cs, ComputedResult.loading())
|
reviewDataProvider.pendingReviewComputationFlow.stateInNow(cs, ComputedResult.loading())
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ internal class GHPRBranchWidgetViewModelImpl(
|
|||||||
override val updateRequired: StateFlow<Boolean> = sharedBranchVm.updateRequired
|
override val updateRequired: StateFlow<Boolean> = sharedBranchVm.updateRequired
|
||||||
|
|
||||||
override val dataLoadingState: StateFlow<ComputedResult<Any>> =
|
override val dataLoadingState: StateFlow<ComputedResult<Any>> =
|
||||||
dataProvider.changesData.changesComputationState.stateInNow(cs, ComputedResult.loading())
|
dataProvider.changesData.changesComputationState().stateInNow(cs, ComputedResult.loading())
|
||||||
|
|
||||||
override val editorReviewEnabled: StateFlow<Boolean> = settings.editorReviewEnabledState
|
override val editorReviewEnabled: StateFlow<Boolean> = settings.editorReviewEnabledState
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.openapi.vcs.actions.VcsContextFactory
|
import com.intellij.openapi.vcs.actions.VcsContextFactory
|
||||||
import com.intellij.platform.util.coroutines.childScope
|
import com.intellij.platform.util.coroutines.childScope
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.CoroutineName
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
import kotlinx.coroutines.channels.BufferOverflow
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
@@ -131,7 +130,7 @@ class UpdateableGHPRTimelineThreadViewModel internal constructor(
|
|||||||
private val _repliesFolded = MutableStateFlow(true)
|
private val _repliesFolded = MutableStateFlow(true)
|
||||||
override val repliesFolded: StateFlow<Boolean> = _repliesFolded.asStateFlow()
|
override val repliesFolded: StateFlow<Boolean> = _repliesFolded.asStateFlow()
|
||||||
|
|
||||||
private val currentChanges = dataProvider.changesData.changesComputationState
|
private val currentChanges = dataProvider.changesData.changesComputationState()
|
||||||
.mapNotNull { it.getOrNull() }
|
.mapNotNull { it.getOrNull() }
|
||||||
.stateIn(cs, SharingStarted.Eagerly, null)
|
.stateIn(cs, SharingStarted.Eagerly, null)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import com.intellij.collaboration.util.ComputedResult
|
|||||||
import com.intellij.collaboration.util.FlowTestUtil.assertEmits
|
import com.intellij.collaboration.util.FlowTestUtil.assertEmits
|
||||||
import com.intellij.collaboration.util.MainDispatcherRule
|
import com.intellij.collaboration.util.MainDispatcherRule
|
||||||
import git4idea.changes.GitBranchComparisonResult
|
import git4idea.changes.GitBranchComparisonResult
|
||||||
import io.mockk.*
|
import io.mockk.coEvery
|
||||||
|
import io.mockk.coVerify
|
||||||
|
import io.mockk.mockk
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.test.TestScope
|
import kotlinx.coroutines.test.TestScope
|
||||||
@@ -80,7 +82,7 @@ class GHPRChangesDataProviderImplTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val inst = createProvider(refs)
|
val inst = createProvider(refs)
|
||||||
inst.changesComputationState.assertEmits(ComputedResult.loading(),
|
inst.changesComputationState().assertEmits(ComputedResult.loading(),
|
||||||
ComputedResult.failure(EXCEPTION),
|
ComputedResult.failure(EXCEPTION),
|
||||||
ComputedResult.loading(),
|
ComputedResult.loading(),
|
||||||
ComputedResult.success(result)) {
|
ComputedResult.success(result)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user