mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] IJPL-173924 Set CommitChangesViewWithToolbarPanel.setBusy reactively
GitOrigin-RevId: 0d4b613443a2de05558e4279fe75881f2dfcc331
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b653201351
commit
36e0c8eccc
+5
-8
@@ -27,7 +27,6 @@ import com.intellij.util.application
|
||||
import com.intellij.util.asDisposable
|
||||
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
import com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -57,11 +56,11 @@ class CommitChangesViewWithToolbarPanel(
|
||||
|
||||
init {
|
||||
refresher.start()
|
||||
}
|
||||
|
||||
@CalledInAny
|
||||
fun setBusy(busy: Boolean) {
|
||||
invokeLaterIfNeeded { changesView.setPaintBusy(busy) }
|
||||
cs.launch(Dispatchers.UI) {
|
||||
refresher.getPendingTasksFlow().collect {
|
||||
isBusy -> changesView.setPaintBusy(isBusy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
@@ -120,7 +119,6 @@ class CommitChangesViewWithToolbarPanel(
|
||||
|
||||
@CalledInAny
|
||||
private fun scheduleRefresh(withDelay: Boolean, @RequiresBackgroundThread callback: Runnable? = null) {
|
||||
setBusy(true)
|
||||
if (withDelay) {
|
||||
refresher.request()
|
||||
}
|
||||
@@ -130,7 +128,6 @@ class CommitChangesViewWithToolbarPanel(
|
||||
cs.launch {
|
||||
refresher.awaitNotBusy()
|
||||
callback?.run()
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -7,6 +7,7 @@ import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.progress.checkCanceled
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.first
|
||||
@@ -29,6 +30,8 @@ class SingleTaskRunner(
|
||||
|
||||
private val runNow = Channel<Unit>(capacity = Channel.CONFLATED)
|
||||
|
||||
fun getPendingTasksFlow(): Flow<Boolean> = requested.combine(busy) { requested, busy -> !requested && !busy }
|
||||
|
||||
private val processorJob = cs.launch(Dispatchers.Default, CoroutineStart.LAZY) {
|
||||
try {
|
||||
while (true) {
|
||||
@@ -73,7 +76,7 @@ class SingleTaskRunner(
|
||||
* Await the state where the task is not executed and there are no requests to do so.
|
||||
*/
|
||||
suspend fun awaitNotBusy() {
|
||||
requested.combine(busy) { requested, busy -> !requested && !busy }.first { it }
|
||||
getPendingTasksFlow().first { it }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
-1
@@ -38,7 +38,6 @@ internal class BackendCommitChangesViewWithToolbarInitializer : CommitChangesVie
|
||||
}
|
||||
|
||||
override fun changedFileStatusChanged() {
|
||||
panel.setBusy(false)
|
||||
panel.scheduleRefresh()
|
||||
val changeListManager = ChangeListManagerImpl.getInstanceImpl(panel.project)
|
||||
ChangesViewManager.getInstance(panel.project).updateProgressComponent(changeListManager.getAdditionalUpdateInfo())
|
||||
|
||||
Reference in New Issue
Block a user