Skip to content

Commit fcd46a6

Browse files
committed
move startup flag handling to processBase
1 parent 580674e commit fcd46a6

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ data class NotificationEtagConfiguration(
9292
@Service(Service.Level.APP)
9393
internal final class NotificationPollingService : Disposable {
9494
private val isFirstPoll = AtomicBoolean(true)
95-
private val isStartup = AtomicBoolean(true)
96-
private val observers = mutableListOf<(Boolean) -> Unit>()
95+
private val observers = mutableListOf<() -> Unit>()
9796
private val alarm = AlarmFactory.getInstance().create(Alarm.ThreadToUse.POOLED_THREAD, this)
9897
private val scope = CoroutineScope(getCoroutineBgContext())
9998
private val pollingIntervalMs = Duration.ofMinutes(10).toMillis()
@@ -178,11 +177,11 @@ internal final class NotificationPollingService : Disposable {
178177
)
179178
}
180179

181-
fun addObserver(observer: (Boolean) -> Unit) = observers.add(observer)
180+
fun addObserver(observer: () -> Unit) = observers.add(observer)
182181

183182
private fun notifyObservers() {
184183
observers.forEach { observer ->
185-
observer(isStartup.getAndSet(false))
184+
observer()
186185
}
187186
}
188187

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ object NotificationMapperUtil {
2424
class ProcessNotificationsBase {
2525
private val notifListener = mutableListOf<NotifListener>()
2626
init {
27-
NotificationPollingService.getInstance().addObserver { isStartup ->
28-
retrieveStartupAndEmergencyNotifications(isStartup)
27+
NotificationPollingService.getInstance().addObserver { ->
28+
retrieveStartupAndEmergencyNotifications()
2929
}
3030
}
3131

@@ -38,7 +38,7 @@ class ProcessNotificationsBase {
3838
return NotificationMapperUtil.mapper.readValue(content)
3939
}
4040

41-
fun retrieveStartupAndEmergencyNotifications(isStartup: Boolean) {
41+
fun retrieveStartupAndEmergencyNotifications() {
4242
// TODO: separates notifications into startup and emergency
4343
// iterates through the 2 lists and processes each notification(if it isn't dismissed)
4444
}

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingServiceTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NotificationPollingServiceTest {
2626
private lateinit var sut: NotificationPollingService
2727
private lateinit var mockResolver: RemoteResourceResolver
2828
private lateinit var mockProvider: RemoteResourceResolverProvider
29-
private lateinit var observer: (Boolean) -> Unit
29+
private lateinit var observer: () -> Unit
3030
private val testPath = Path.of("/test/path")
3131

3232
@BeforeEach
@@ -47,8 +47,8 @@ class NotificationPollingServiceTest {
4747
providerField.set(sut, mockProvider)
4848

4949
// Create mock observers
50-
observer = mockk<(Boolean) -> Unit>()
51-
every { observer.invoke(any()) } just Runs
50+
observer = mockk<() -> Unit>()
51+
every { observer.invoke() } just Runs
5252

5353
val observersField = NotificationPollingService::class.java
5454
.getDeclaredField("observers")
@@ -78,7 +78,7 @@ class NotificationPollingServiceTest {
7878
} returns "same"
7979
sut.startPolling()
8080
}
81-
verify(exactly = 0) { observer.invoke(any()) }
81+
verify(exactly = 0) { observer.invoke() }
8282
}
8383

8484
@Test
@@ -92,7 +92,7 @@ class NotificationPollingServiceTest {
9292
} returns "same"
9393
sut.startPolling()
9494
}
95-
verify(exactly = 1) { observer.invoke(any()) }
95+
verify(exactly = 1) { observer.invoke() }
9696
}
9797

9898
@Test
@@ -106,6 +106,6 @@ class NotificationPollingServiceTest {
106106
} returns "newEtag"
107107
sut.startPolling()
108108
}
109-
verify(exactly = 1) { observer.invoke(any()) }
109+
verify(exactly = 1) { observer.invoke() }
110110
}
111111
}

0 commit comments

Comments
 (0)