Skip to content

Commit 71e90d3

Browse files
Merge branch 'samgst/notificationPolling' into samgst/notificationStates
2 parents 34cbdfa + fcd46a6 commit 71e90d3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
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
@@ -63,8 +63,7 @@ object NotificationEndpoint {
6363
@Service(Service.Level.APP)
6464
internal final class NotificationPollingService : Disposable {
6565
private val isFirstPoll = AtomicBoolean(true)
66-
private val isStartup = AtomicBoolean(true)
67-
private val observers = mutableListOf<(Boolean) -> Unit>()
66+
private val observers = mutableListOf<() -> Unit>()
6867
private val alarm = AlarmFactory.getInstance().create(Alarm.ThreadToUse.POOLED_THREAD, this)
6968
private val scope = CoroutineScope(getCoroutineBgContext())
7069
private val pollingIntervalMs = Duration.ofMinutes(10).toMillis()
@@ -149,11 +148,11 @@ internal final class NotificationPollingService : Disposable {
149148
)
150149
}
151150

152-
fun addObserver(observer: (Boolean) -> Unit) = observers.add(observer)
151+
fun addObserver(observer: () -> Unit) = observers.add(observer)
153152

154153
private fun notifyObservers() {
155154
observers.forEach { observer ->
156-
observer(isStartup.getAndSet(false))
155+
observer()
157156
}
158157
}
159158

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)