Skip to content

Commit 34cbdfa

Browse files
committed
comments
1 parent 9b60583 commit 34cbdfa

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPersistantState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ data class NotificationDismissalConfiguration(
3535
var dismissedNotificationIds: MutableSet<String> = mutableSetOf(),
3636
)
3737

38-
3938
@State(name = "notificationEtag", storages = [Storage("aws.xml")])
4039
class NotificationEtagState : PersistentStateComponent<NotificationEtagConfiguration> {
4140
private var state = NotificationEtagConfiguration()

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ package software.aws.toolkits.jetbrains.core.notifications
66
import com.fasterxml.jackson.module.kotlin.readValue
77
import com.intellij.openapi.Disposable
88
import com.intellij.openapi.application.ApplicationManager
9-
import com.intellij.openapi.components.PersistentStateComponent
109
import com.intellij.openapi.components.Service
11-
import com.intellij.openapi.components.State
12-
import com.intellij.openapi.components.Storage
1310
import com.intellij.util.Alarm
1411
import com.intellij.util.AlarmFactory
1512
import com.intellij.util.io.HttpRequests

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.openapi.project.Project
1515
import software.aws.toolkits.core.utils.inputStream
1616
import software.aws.toolkits.jetbrains.utils.notifyStickyWithData
1717
import java.nio.file.Paths
18+
import java.util.concurrent.atomic.AtomicBoolean
1819

1920
object NotificationMapperUtil {
2021
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
@@ -25,9 +26,10 @@ class ProcessNotificationsBase(
2526
private val project: Project,
2627
) {
2728
private val notifListener = mutableListOf<NotifListener>()
29+
private var isStartup: AtomicBoolean = AtomicBoolean(true)
2830
init {
29-
NotificationPollingService.getInstance().addObserver { isStartup ->
30-
retrieveStartupAndEmergencyNotifications(isStartup)
31+
NotificationPollingService.getInstance().addObserver {
32+
retrieveStartupAndEmergencyNotifications()
3133
}
3234
}
3335

@@ -40,7 +42,7 @@ class ProcessNotificationsBase(
4042
return NotificationMapperUtil.mapper.readValue(content)
4143
}
4244

43-
fun retrieveStartupAndEmergencyNotifications(isStartup: Boolean) {
45+
fun retrieveStartupAndEmergencyNotifications() {
4446
val notifications = getNotificationsFromFile()
4547

4648
notifications?.let { notificationsList ->
@@ -51,10 +53,16 @@ class ProcessNotificationsBase(
5153
?: Pair(emptyList(), emptyList())
5254

5355
val dismissalState = NotificationDismissalState.getInstance()
54-
(if (isStartup) startupNotifications else emptyList())
55-
.plus(emergencyNotifications)
56-
.filter { !dismissalState.isDismissed(it.id) }
57-
.forEach { processNotification(project, it) }
56+
val startupList = if (isStartup.compareAndSet(true, false)) {
57+
startupNotifications
58+
} else {
59+
emptyList()
60+
}
61+
62+
val combinedNotifications = startupList.plus(emergencyNotifications)
63+
val activeNotifications = combinedNotifications.filter { !dismissalState.isDismissed(it.id) }
64+
65+
activeNotifications.forEach { processNotification(project, it) }
5866
}
5967
}
6068

0 commit comments

Comments
 (0)