fix teleport tag and icons (#303)

This commit is contained in:
callebtc
2025-08-24 02:03:00 +02:00
committed by GitHub
parent 37c8c79310
commit cb7b01ad81
4 changed files with 34 additions and 5 deletions
@@ -149,8 +149,28 @@ class LocationChannelManager private constructor(private val context: Context) {
*/ */
fun select(channel: ChannelID) { fun select(channel: ChannelID) {
Log.d(TAG, "Selected channel: ${channel.displayName}") Log.d(TAG, "Selected channel: ${channel.displayName}")
_selectedChannel.postValue(channel) // Use synchronous set to avoid race with background recomputation
_selectedChannel.value = channel
saveChannelSelection(channel) saveChannelSelection(channel)
// Immediately recompute teleported status against the latest known location
lastLocation?.let { location ->
when (channel) {
is ChannelID.Mesh -> {
_teleported.postValue(false)
}
is ChannelID.Location -> {
val currentGeohash = Geohash.encode(
latitude = location.latitude,
longitude = location.longitude,
precision = channel.channel.level.precision
)
val isTeleportedNow = currentGeohash != channel.channel.geohash
_teleported.postValue(isTeleportedNow)
Log.d(TAG, "Teleported (immediate recompute): $isTeleportedNow (current: $currentGeohash, selected: ${channel.channel.geohash})")
}
}
}
} }
/** /**
@@ -181,7 +181,8 @@ class NostrGeohashService(
content = content, content = content,
geohash = channel.geohash, geohash = channel.geohash,
senderIdentity = identity, senderIdentity = identity,
nickname = nickname nickname = nickname,
teleported = teleported
) )
val nostrRelayManager = NostrRelayManager.getInstance(application) val nostrRelayManager = NostrRelayManager.getInstance(application)
@@ -99,7 +99,8 @@ object NostrProtocol {
content: String, content: String,
geohash: String, geohash: String,
senderIdentity: NostrIdentity, senderIdentity: NostrIdentity,
nickname: String? = null nickname: String? = null,
teleported: Boolean = false
): NostrEvent { ): NostrEvent {
val tags = mutableListOf<List<String>>() val tags = mutableListOf<List<String>>()
tags.add(listOf("g", geohash)) tags.add(listOf("g", geohash))
@@ -108,6 +109,11 @@ object NostrProtocol {
tags.add(listOf("n", nickname)) tags.add(listOf("n", nickname))
} }
if (teleported) {
// Use tag consistent with event handlers ("t","teleport")
tags.add(listOf("t", "teleport"))
}
val event = NostrEvent( val event = NostrEvent(
pubkey = senderIdentity.publicKeyHex, pubkey = senderIdentity.publicKeyHex,
createdAt = (System.currentTimeMillis() / 1000).toInt(), createdAt = (System.currentTimeMillis() / 1000).toInt(),
@@ -5,6 +5,8 @@ import androidx.compose.foundation.*
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.* import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.outlined.Explore
import androidx.compose.material.icons.outlined.LocationOn
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.livedata.observeAsState
@@ -182,8 +184,8 @@ private fun GeohashPersonItem(
// Use appropriate Material icon (closest match to iOS SF Symbols) // Use appropriate Material icon (closest match to iOS SF Symbols)
val icon = when (iconName) { val icon = when (iconName) {
"face.dashed" -> Icons.Default.Face // Use regular face icon (no dashed variant in Material) "face.dashed" -> Icons.Outlined.Explore
else -> Icons.Default.Face else -> Icons.Outlined.LocationOn
} }
Icon( Icon(