mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:45:19 +00:00
Ignore self when presenting message actions (#625)
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -1489,6 +1489,8 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
|
|
||||||
// Track ourselves as active participant
|
// Track ourselves as active participant
|
||||||
recordGeoParticipant(pubkeyHex: identity.publicKeyHex)
|
recordGeoParticipant(pubkeyHex: identity.publicKeyHex)
|
||||||
|
let shortKey = "nostr:" + identity.publicKeyHex.prefix(TransportConfig.nostrShortKeyDisplayLength)
|
||||||
|
nostrKeyMapping[shortKey] = identity.publicKeyHex
|
||||||
SecureLogger.debug("GeoTeleport: sent geo message pub=\(identity.publicKeyHex.prefix(8))… teleported=\(LocationChannelManager.shared.teleported)", category: .session)
|
SecureLogger.debug("GeoTeleport: sent geo message pub=\(identity.publicKeyHex.prefix(8))… teleported=\(LocationChannelManager.shared.teleported)", category: .session)
|
||||||
|
|
||||||
// If we tagged this as teleported, also mark our pubkey in teleportedGeo for UI
|
// If we tagged this as teleported, also mark our pubkey in teleportedGeo for UI
|
||||||
@@ -1884,6 +1886,33 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
geohashPeople = people
|
geohashPeople = people
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func isSelfSender(peerID: String?, displayName: String?) -> Bool {
|
||||||
|
guard let peerID else { return false }
|
||||||
|
if peerID == meshService.myPeerID { return true }
|
||||||
|
let lowerPeer = peerID.lowercased()
|
||||||
|
guard lowerPeer.hasPrefix("nostr") else { return false }
|
||||||
|
|
||||||
|
if let mapped = nostrKeyMapping[peerID]?.lowercased(),
|
||||||
|
let gh = currentGeohash,
|
||||||
|
let myIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh) {
|
||||||
|
if mapped == myIdentity.publicKeyHex.lowercased() { return true }
|
||||||
|
}
|
||||||
|
|
||||||
|
if let gh = currentGeohash,
|
||||||
|
let myIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh) {
|
||||||
|
let myLower = myIdentity.publicKeyHex.lowercased()
|
||||||
|
let shortLen = TransportConfig.nostrShortKeyDisplayLength
|
||||||
|
let shortKey = "nostr:" + myLower.prefix(shortLen)
|
||||||
|
if lowerPeer == shortKey { return true }
|
||||||
|
let suffix = myIdentity.publicKeyHex.suffix(4)
|
||||||
|
let expected = (nickname + "#" + suffix).lowercased()
|
||||||
|
if let display = displayName?.lowercased(), display == expected { return true }
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private func startGeoParticipantsTimer() {
|
private func startGeoParticipantsTimer() {
|
||||||
stopGeoParticipantsTimer()
|
stopGeoParticipantsTimer()
|
||||||
geoParticipantsTimer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) { [weak self] _ in
|
geoParticipantsTimer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) { [weak self] _ in
|
||||||
|
|||||||
@@ -462,8 +462,13 @@ struct ContentView: View {
|
|||||||
selectedMessageSender = viewModel.messages.last(where: { $0.senderPeerID == peerID && $0.sender != "system" })?.sender
|
selectedMessageSender = viewModel.messages.last(where: { $0.senderPeerID == peerID && $0.sender != "system" })?.sender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if viewModel.isSelfSender(peerID: selectedMessageSenderID, displayName: selectedMessageSender) {
|
||||||
|
selectedMessageSender = nil
|
||||||
|
selectedMessageSenderID = nil
|
||||||
|
} else {
|
||||||
showMessageActions = true
|
showMessageActions = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.onOpenURL { url in
|
.onOpenURL { url in
|
||||||
guard url.scheme == "bitchat", url.host == "geohash" else { return }
|
guard url.scheme == "bitchat", url.host == "geohash" else { return }
|
||||||
let gh = url.path.trimmingCharacters(in: CharacterSet(charactersIn: "/")).lowercased()
|
let gh = url.path.trimmingCharacters(in: CharacterSet(charactersIn: "/")).lowercased()
|
||||||
|
|||||||
Reference in New Issue
Block a user