From 8db6ccfdc3bb93d291251324b830ec4289b5f4c4 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Mon, 27 Jul 2026 13:06:00 +0200 Subject: [PATCH] fix location channel lifecycle bug --- .../android/ui/LocationChannelsSheet.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt b/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt index 92c10264..dd892cfc 100644 --- a/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt +++ b/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt @@ -51,6 +51,7 @@ import androidx.activity.result.contract.ActivityResultContracts import com.bitchat.android.nostr.NearbyNotesController import com.bitchat.android.nostr.geohashesForSampling import com.bitchat.android.ui.theme.BASE_FONT_SIZE +import androidx.lifecycle.compose.LifecycleResumeEffect import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.bitchat.android.R import com.bitchat.android.core.ui.component.sheet.BitchatBottomSheet @@ -588,15 +589,16 @@ fun LocationChannelsSheet( } } - DisposableEffect(isPresented, permissionState, locationServicesEnabled) { - if (isPresented && - permissionState == LocationChannelManager.PermissionState.AUTHORIZED && - locationServicesEnabled - ) { - locationManager.refreshChannels() - locationManager.beginLiveRefresh() + LifecycleResumeEffect(isPresented, locationServicesEnabled) { + if (isPresented && locationServicesEnabled) { + locationManager.enableLocationChannels() + if (locationManager.permissionState.value == + LocationChannelManager.PermissionState.AUTHORIZED + ) { + locationManager.beginLiveRefresh() + } } - onDispose { locationManager.endLiveRefresh() } + onPauseOrDispose { locationManager.endLiveRefresh() } } // Sampling management: update sampling when channels/bookmarks change