From f79451b615f63f38543a3d96fed8873640092728 Mon Sep 17 00:00:00 2001 From: a1denvalu3 <43107113+a1denvalu3@users.noreply.github.com> Date: Sat, 31 Jan 2026 16:42:20 +0100 Subject: [PATCH] fix(geohash): cleanup sampling subscriptions when closing location sheet (#659) - Added DisposableEffect to LocationChannelsSheet to ensure cleanup runs when composable is removed - Fixed ChatViewModel.endGeohashSampling() to correctly delegate to GeohashViewModel instead of being a no-op - Prevents lingering kind 20001 subscriptions after closing the sheet --- app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt | 2 +- .../java/com/bitchat/android/ui/LocationChannelsSheet.kt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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