Skip to content

Commit f79451b

Browse files
authored
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
1 parent 06d2665 commit f79451b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ class ChatViewModel(
10461046
* End geohash sampling
10471047
*/
10481048
fun endGeohashSampling() {
1049-
// No-op in refactored architecture; sampling subscriptions are short-lived
1049+
geohashViewModel.endGeohashSampling()
10501050
}
10511051

10521052
/**

app/src/main/java/com/bitchat/android/ui/LocationChannelsSheet.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,13 @@ fun LocationChannelsSheet(
542542
viewModel.endGeohashSampling()
543543
}
544544
}
545+
546+
// Ensure cleanup when the composable is destroyed (e.g. removed from parent composition)
547+
DisposableEffect(Unit) {
548+
onDispose {
549+
viewModel.endGeohashSampling()
550+
}
551+
}
545552
}
546553

547554
@Composable

0 commit comments

Comments
 (0)