diff --git a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt index 5456ca4d..cc6a5808 100644 --- a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt +++ b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt @@ -1046,7 +1046,7 @@ class ChatViewModel( * End geohash sampling */ fun endGeohashSampling() { - // No-op in refactored architecture; sampling subscriptions are short-lived + geohashViewModel.endGeohashSampling() } /** 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 48021b3f..5bf7003b 100644 --- a/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt +++ b/app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt @@ -542,6 +542,13 @@ fun LocationChannelsSheet( viewModel.endGeohashSampling() } } + + // Ensure cleanup when the composable is destroyed (e.g. removed from parent composition) + DisposableEffect(Unit) { + onDispose { + viewModel.endGeohashSampling() + } + } } @Composable