mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:45:19 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c55e2d4b44 | ||
|
|
e44ba3e5c7 | ||
|
|
f59139c33c |
@@ -719,11 +719,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
self.processedNostrEvents.insert(event.id)
|
self.processedNostrEvents.insert(event.id)
|
||||||
if let gh = self.currentGeohash,
|
if let gh = self.currentGeohash,
|
||||||
let myGeoIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh),
|
let myGeoIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh),
|
||||||
myGeoIdentity.publicKeyHex.lowercased() == event.pubkey.lowercased() {
|
myGeoIdentity.publicKeyHex.lowercased() == event.pubkey.lowercased() { return }
|
||||||
// Skip very recent self-echo from relay, but allow older events (e.g., after app restart)
|
|
||||||
let eventTime = Date(timeIntervalSince1970: TimeInterval(event.created_at))
|
|
||||||
if Date().timeIntervalSince(eventTime) < 15 { return }
|
|
||||||
}
|
|
||||||
if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 {
|
if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 {
|
||||||
let nick = nickTag[1]
|
let nick = nickTag[1]
|
||||||
self.geoNicknames[event.pubkey.lowercased()] = nick
|
self.geoNicknames[event.pubkey.lowercased()] = nick
|
||||||
@@ -837,14 +833,16 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
self.sentReadReceipts.insert(messageId)
|
self.sentReadReceipts.insert(messageId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Notify for truly unread and recent messages when not viewing
|
// Optionally notify if app backgrounded and message is truly unread
|
||||||
if shouldMarkUnread {
|
#if os(iOS)
|
||||||
|
if shouldMarkUnread && UIApplication.shared.applicationState != .active {
|
||||||
NotificationService.shared.sendPrivateMessageNotification(
|
NotificationService.shared.sendPrivateMessageNotification(
|
||||||
from: senderName,
|
from: senderName,
|
||||||
message: pm.content,
|
message: pm.content,
|
||||||
peerID: convKey
|
peerID: convKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
self.objectWillChange.send()
|
self.objectWillChange.send()
|
||||||
case .delivered:
|
case .delivered:
|
||||||
@@ -1391,12 +1389,11 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
category: SecureLogger.session, level: .info)
|
category: SecureLogger.session, level: .info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Skip only very recent self-echo from relay; include older self events for hydration
|
// Skip our own events (we already locally echoed)
|
||||||
if let gh = self.currentGeohash,
|
if let gh = self.currentGeohash,
|
||||||
let myGeoIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh),
|
let myGeoIdentity = try? NostrIdentityBridge.deriveIdentity(forGeohash: gh),
|
||||||
myGeoIdentity.publicKeyHex.lowercased() == event.pubkey.lowercased() {
|
myGeoIdentity.publicKeyHex.lowercased() == event.pubkey.lowercased() {
|
||||||
let eventTime = Date(timeIntervalSince1970: TimeInterval(event.created_at))
|
return
|
||||||
if Date().timeIntervalSince(eventTime) < 15 { return }
|
|
||||||
}
|
}
|
||||||
// Cache nickname from tag if present
|
// Cache nickname from tag if present
|
||||||
if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 {
|
if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 {
|
||||||
@@ -1524,14 +1521,19 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
} else {
|
} else {
|
||||||
// pared back: omit defer READ log
|
// pared back: omit defer READ log
|
||||||
}
|
}
|
||||||
// Notify for truly unread and recent messages when not viewing
|
// Notify only when app is backgrounded and not viewing, and only if not already read
|
||||||
|
#if os(iOS)
|
||||||
if !isViewing && shouldMarkUnread {
|
if !isViewing && shouldMarkUnread {
|
||||||
|
if UIApplication.shared.applicationState != .active {
|
||||||
NotificationService.shared.sendPrivateMessageNotification(
|
NotificationService.shared.sendPrivateMessageNotification(
|
||||||
from: senderName,
|
from: senderName,
|
||||||
message: pm.content,
|
message: pm.content,
|
||||||
peerID: convKey
|
peerID: convKey
|
||||||
)
|
)
|
||||||
|
// pared back: omit notification log
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
self.objectWillChange.send()
|
self.objectWillChange.send()
|
||||||
default:
|
default:
|
||||||
// Handle delivered/read receipts for our sent messages
|
// Handle delivered/read receipts for our sent messages
|
||||||
|
|||||||
Reference in New Issue
Block a user