Prevent multiple concurrent 'checkHideNonConfiguredNotifications' calls
This commit is contained in:
+15
-7
@@ -23,6 +23,7 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
object ConfigureKotlinNotificationManager: KotlinSingleNotificationManager<ConfigureKotlinNotification> {
|
||||
@@ -66,16 +67,23 @@ interface KotlinSingleNotificationManager<in T: Notification> {
|
||||
}
|
||||
}
|
||||
|
||||
private val checkInProgress = AtomicBoolean(false)
|
||||
|
||||
fun checkHideNonConfiguredNotifications(project: Project) {
|
||||
if (ConfigureKotlinNotificationManager.getVisibleNotifications(project).isNotEmpty()) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
DumbService.getInstance(project).waitForSmartMode()
|
||||
if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
||||
}
|
||||
if (checkInProgress.get() || ConfigureKotlinNotificationManager.getVisibleNotifications(project).isEmpty()) return
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
if (!checkInProgress.compareAndSet(false, true)) return@executeOnPooledThread
|
||||
|
||||
DumbService.getInstance(project).waitForSmartMode()
|
||||
if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
||||
checkInProgress.set(false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkInProgress.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user