@@ -77,7 +77,6 @@ import to.bitkit.repositories.CurrencyRepo
7777import to.bitkit.repositories.HealthRepo
7878import to.bitkit.repositories.LightningRepo
7979import to.bitkit.repositories.WalletRepo
80- import to.bitkit.services.CoreService
8180import to.bitkit.services.LdkNodeEventBus
8281import to.bitkit.ui.Routes
8382import to.bitkit.ui.components.Sheet
@@ -95,7 +94,6 @@ class AppViewModel @Inject constructor(
9594 private val keychain : Keychain ,
9695 private val lightningRepo : LightningRepo ,
9796 private val walletRepo : WalletRepo ,
98- private val coreService : CoreService ,
9997 private val ldkNodeEventBus : LdkNodeEventBus ,
10098 private val settingsStore : SettingsStore ,
10199 private val currencyRepo : CurrencyRepo ,
@@ -112,8 +110,14 @@ class AppViewModel @Inject constructor(
112110 var splashVisible by mutableStateOf(true )
113111 private set
114112
115- var isGeoBlocked by mutableStateOf<Boolean ?>(null )
116- private set
113+ val isGeoBlocked = lightningRepo.lightningState.map { it.isGeoBlocked }
114+ .stateIn(
115+ viewModelScope,
116+ SharingStarted .WhileSubscribed (
117+ 5000
118+ ),
119+ false
120+ )
117121
118122 private val _sendUiState = MutableStateFlow (SendUiState ())
119123 val sendUiState = _sendUiState .asStateFlow()
@@ -184,10 +188,12 @@ class AppViewModel @Inject constructor(
184188 delay(500 )
185189 splashVisible = false
186190 }
191+ viewModelScope.launch {
192+ lightningRepo.updateGeoBlockState()
193+ }
187194
188195 observeLdkNodeEvents()
189196 observeSendEvents()
190- checkGeoStatus()
191197 }
192198
193199 private fun observeLdkNodeEvents () {
@@ -271,16 +277,6 @@ class AppViewModel @Inject constructor(
271277 }
272278 }
273279
274- private fun checkGeoStatus () {
275- viewModelScope.launch {
276- try {
277- isGeoBlocked = coreService.checkGeoStatus()
278- } catch (e: Throwable ) {
279- Logger .error(" Failed to check geo status: ${e.message} " , e, context = TAG )
280- }
281- }
282- }
283-
284280 // region send
285281
286282 private fun observeSendEvents () {
0 commit comments