Skip to content

Commit 3bcc9ff

Browse files
committed
fix: return early when the app is in foreground
1 parent 73e576f commit 3bcc9ff

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

app/src/main/java/to/bitkit/androidServices/LightningNodeService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ class LightningNodeService : Service() {
112112
}
113113

114114
private suspend fun handleChannelReady(event: Event.ChannelReady) {
115+
// When the app is in the foreground, AppViewModel handles this event and shows the receive
116+
// sheet. Running here would consume the CJIT dedup gate (insertActivityFromCjit) and then
117+
// skip the notification (foreground), leaving the in-app handler to see Duplicate and show
118+
// nothing — so defer entirely.
119+
if (App.currentActivity?.value != null) return
120+
115121
val command = NotifyChannelReady.Command(event = event, includeNotification = true)
116122
notifyChannelReadyHandler(command).onSuccess {
117123
Logger.debug("Channel ready notification result: $it", context = TAG)

app/src/test/java/to/bitkit/androidServices/LightningNodeServiceTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ class LightningNodeServiceTest : BaseUnitTest() {
630630
it.extras.getString(Notification.EXTRA_TITLE) == cjitTitle
631631
}
632632
assertNull(notification, "CJIT notification should NOT be present in foreground")
633+
// Defers to AppViewModel: must not invoke the handler, or it would consume the CJIT dedup gate
634+
verify(notifyChannelReadyHandler, never()).invoke(any())
633635
}
634636

635637
@Test

0 commit comments

Comments
 (0)