Skip to content

Commit 0466cee

Browse files
committed
fix: edge case when the FG service is timed out with the app in FG, the LN node would keep running after app ON_STOP
1 parent e571137 commit 0466cee

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

app/src/main/java/to/bitkit/ui/ContentView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ fun ContentView(
274274
}
275275

276276
Lifecycle.Event.ON_STOP -> {
277-
val keptAliveByService = notificationsGranted && keepActiveInBackground
277+
val keptAliveByService = notificationsGranted &&
278+
keepActiveInBackground &&
279+
appViewModel.isForegroundServiceRunning()
278280
if (walletExists && !isRecoveryMode && !keptAliveByService) {
279281
walletViewModel.stop()
280282
}

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ import to.bitkit.repositories.WidgetsRepo
143143
import to.bitkit.services.AppUpdaterService
144144
import to.bitkit.services.CoreService
145145
import to.bitkit.services.MigrationService
146+
import to.bitkit.services.NodeServiceFgState
146147
import to.bitkit.ui.Routes
147148
import to.bitkit.ui.components.Sheet
148149
import to.bitkit.ui.shared.toast.ToastEventBus
@@ -200,6 +201,7 @@ class AppViewModel @Inject constructor(
200201
private val transferRepo: TransferRepo,
201202
private val migrationService: MigrationService,
202203
private val coreService: CoreService,
204+
private val nodeServiceFgState: NodeServiceFgState,
203205
private val pubkyRepo: PubkyRepo,
204206
private val publicPaykitRepo: PublicPaykitRepo,
205207
private val privatePaykitRepo: PrivatePaykitRepo,
@@ -2734,6 +2736,8 @@ class AppViewModel @Inject constructor(
27342736
cacheStore.clearBackgroundReceive()
27352737
showTransactionSheet(details)
27362738
}
2739+
2740+
fun isForegroundServiceRunning(): Boolean = nodeServiceFgState.isForegroundServiceRunning
27372741
// endregion
27382742

27392743
// region Sheets

0 commit comments

Comments
 (0)