Skip to content

Commit 29a1706

Browse files
committed
Added delay to throttling popup appearance
1 parent 4b594df commit 29a1706

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/persistence/NotificationsPersistenceState.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ data class NotificationsState(
4040
var requestRegistrationLastNotified: Instant? = null,
4141
@OptionTag(converter = InstantConverter::class)
4242
var aggressiveUpdateLastNotified: Instant? = null,
43+
@OptionTag(converter = InstantConverter::class)
44+
var closeButtonLastClickedTime: Instant? = null,
4345
)

src/main/kotlin/org/digma/intellij/plugin/ui/common/LoadStatusPanel.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.digma.intellij.plugin.common.EDT
1616
import org.digma.intellij.plugin.common.newerThan
1717
import org.digma.intellij.plugin.icons.AppIcons
1818
import org.digma.intellij.plugin.loadstatus.LoadStatusService
19+
import org.digma.intellij.plugin.persistence.NotificationsPersistenceState
1920
import org.digma.intellij.plugin.posthog.ActivityMonitor
2021
import org.digma.intellij.plugin.posthog.UserActionOrigin
2122
import org.digma.intellij.plugin.ui.panels.DigmaResettablePanel
@@ -25,6 +26,8 @@ import java.awt.Dimension
2526
import java.awt.GridLayout
2627
import java.awt.event.MouseAdapter
2728
import java.awt.event.MouseEvent
29+
import java.time.Duration
30+
import java.time.Instant
2831
import javax.swing.BorderFactory
2932
import javax.swing.Box
3033
import javax.swing.BoxLayout
@@ -115,6 +118,8 @@ class LoadStatusPanel(val project: Project) : DigmaResettablePanel() {
115118
closeButton.addActionListener {
116119
isVisible = false
117120

121+
service<NotificationsPersistenceState>().state.closeButtonLastClickedTime = Instant.now()
122+
118123
Backgroundable.ensurePooledThread {
119124
ActivityMonitor.getInstance(project).registerCloseThrottlingMessage(service.lastLoadStatus.throttlingType.toString())
120125
if (service.lastLoadStatus.throttlingType == "ExtendedObservability")
@@ -146,8 +151,15 @@ class LoadStatusPanel(val project: Project) : DigmaResettablePanel() {
146151
return currentBackendVersion.newerThan(closeButtonBackendVersion)
147152
}
148153

154+
private fun wasClosedRecently(): Boolean {
155+
val lastCloseTime = service<NotificationsPersistenceState>().state.closeButtonLastClickedTime ?: return false
156+
val currentTime = Instant.now()
157+
val duration = Duration.between(lastCloseTime, currentTime)
158+
return duration.toHours() < 24
159+
}
160+
149161
override fun reset() {
150-
if (service.lastLoadStatus.occurredRecently) {
162+
if (service.lastLoadStatus.occurredRecently && !wasClosedRecently()) {
151163
if (!isVisible) {
152164
isVisible = true
153165
ActivityMonitor.getInstance(project).registerLoadWarning(

0 commit comments

Comments
 (0)