mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 16:25:21 +00:00
feat(notifications): unify DM notifications across transports; notify for unread+recent even in foreground; delegate suppresses if chat open
This commit is contained in:
@@ -833,16 +833,14 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
self.sentReadReceipts.insert(messageId)
|
self.sentReadReceipts.insert(messageId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Optionally notify if app backgrounded and message is truly unread
|
// Notify for truly unread and recent messages when not viewing
|
||||||
#if os(iOS)
|
if shouldMarkUnread {
|
||||||
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:
|
||||||
@@ -1521,19 +1519,14 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
} else {
|
} else {
|
||||||
// pared back: omit defer READ log
|
// pared back: omit defer READ log
|
||||||
}
|
}
|
||||||
// Notify only when app is backgrounded and not viewing, and only if not already read
|
// Notify for truly unread and recent messages when not viewing
|
||||||
#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