@@ -8,6 +8,7 @@ import androidx.work.workDataOf
88import dagger.assisted.Assisted
99import dagger.assisted.AssistedInject
1010import kotlinx.coroutines.CompletableDeferred
11+ import kotlinx.coroutines.delay
1112import kotlinx.coroutines.flow.first
1213import kotlinx.coroutines.withTimeout
1314import kotlinx.serialization.json.JsonObject
@@ -241,6 +242,15 @@ class WakeNodeWorker @AssistedInject constructor(
241242 }
242243
243244 private suspend fun deliver () {
245+ // Send notification first
246+ bestAttemptContent?.run {
247+ appContext.pushNotification(title, body)
248+ Logger .info(" Delivered notification" , context = TAG )
249+ }
250+
251+ // Delay briefly to allow app to come to foreground if user clicked notification
252+ delay(500 )
253+
244254 // Only stop node if app is not in foreground
245255 // LightningNodeService will keep node running in background when notifications are enabled
246256 if (App .currentActivity?.value == null ) {
@@ -250,11 +260,6 @@ class WakeNodeWorker @AssistedInject constructor(
250260 Logger .debug(" App in foreground, keeping node running" , context = TAG )
251261 }
252262
253- bestAttemptContent?.run {
254- appContext.pushNotification(title, body)
255- Logger .info(" Delivered notification" , context = TAG )
256- }
257-
258263 deliverSignal.complete(Unit )
259264 }
260265
0 commit comments