mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 07:45:22 +00:00
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:
@@ -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]"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user