Implement Geohash Presence (Heartbeats) (#576)

* geohash announce

* only for some geohashes

* global presence right away

* jitter delays

* show ? people for high-precision geohashes

* 1000 events
This commit is contained in:
callebtc
2026-01-13 03:23:53 +07:00
committed by GitHub
parent 654d385b6d
commit d164b3f9bc
7 changed files with 229 additions and 13 deletions
@@ -706,7 +706,16 @@ private fun meshCount(viewModel: ChatViewModel): Int {
@Composable
private fun geohashTitleWithCount(channel: GeohashChannel, participantCount: Int): String {
val ctx = androidx.compose.ui.platform.LocalContext.current
val peopleText = ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, participantCount, participantCount)
// For high precision channels (Neighborhood, Block) where we don't broadcast presence,
// show "? people" instead of "0 people" to avoid misleading "nobody is here" indication.
val isHighPrecision = channel.level.precision > 5
val peopleText = if (isHighPrecision && participantCount == 0) {
ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, 0, 0).replace("0", "?")
} else {
ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, participantCount, participantCount)
}
val levelName = when (channel.level) {
com.bitchat.android.geohash.GeohashChannelLevel.BUILDING -> "Building" // iOS: precision 8 for location notes
com.bitchat.android.geohash.GeohashChannelLevel.BLOCK -> stringResource(com.bitchat.android.R.string.location_level_block)
@@ -721,7 +730,15 @@ private fun geohashTitleWithCount(channel: GeohashChannel, participantCount: Int
@Composable
private fun geohashHashTitleWithCount(geohash: String, participantCount: Int): String {
val ctx = androidx.compose.ui.platform.LocalContext.current
val peopleText = ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, participantCount, participantCount)
val level = levelForLength(geohash.length)
val isHighPrecision = level.precision > 5
val peopleText = if (isHighPrecision && participantCount == 0) {
ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, 0, 0).replace("0", "?")
} else {
ctx.resources.getQuantityString(com.bitchat.android.R.plurals.people_count, participantCount, participantCount)
}
return "#$geohash [$peopleText]"
}