IJPL-13205 Fix setting status label update when deleting remote data

Since the even handler runs in a different thread from the progress modal, `ModalityKt.defaultModalityImpl()`
won't be able to get it from `ProgressManager.getInstanceOrNull()?.currentProgressModality`, causing the
modality state to fall back to non-modal, delaying the label update until after the settings dialog is closed.

It's fixed by just storing the settings dialog modality state before showing the progress modal and passing
it to `runInEdt` explicitly.

Signed-off-by: Sergey Pak <sergey.pak@jetbrains.com>

GitOrigin-RevId: ae45788cc3f16bb92e2bad666ba16b733762a216
This commit is contained in:
Tomek jean Mańko
2024-07-10 18:22:48 +00:00
committed by intellij-monorepo-bot
parent af89084372
commit 5bfc566e1c
@@ -7,6 +7,7 @@ import com.intellij.ide.plugins.PluginManagerConfigurable
import com.intellij.ide.plugins.PluginStateManager
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ApplicationNamesInfo
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.application.ex.ApplicationEx
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.components.impl.stores.stateStore
@@ -359,11 +360,14 @@ internal class SettingsSyncConfigurable : BoundConfigurable(message("title.setti
}
private fun disableAndRemoveData() {
val modality = ModalityState.current();
object : Task.Modal(null, message("disable.remove.data.title"), false) {
override fun run(indicator: ProgressIndicator) {
val cdl = CountDownLatch(1)
SettingsSyncEvents.getInstance().fireSettingsChanged(SyncSettingsEvent.DeleteServerData { result ->
cdl.countDown()
when (result) {
is DeleteServerDataResult.Error -> {
runInEdt {
@@ -371,12 +375,13 @@ internal class SettingsSyncConfigurable : BoundConfigurable(message("title.setti
}
}
DeleteServerDataResult.Success -> {
runInEdt {
runInEdt(modality) {
updateStatusInfo()
}
}
}
})
cdl.await(1, TimeUnit.MINUTES)
}
}.queue()