mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
Clear notifications for fully read rooms using the event's timestamp instead of delivery date
This commit is contained in:
@@ -17,6 +17,7 @@ struct NotificationItemProxyMockConfiguration {
|
||||
let messageLikeContent = MessageLikeEventContent.roomMessage(messageType: messageType, inReplyToEventId: nil)
|
||||
let event = TimelineEventSDKMock()
|
||||
event.eventIdReturnValue = UUID().uuidString
|
||||
event.timestampReturnValue = 0
|
||||
event.contentReturnValue = .messageLike(content: messageLikeContent)
|
||||
return .timeline(event: event)
|
||||
}()
|
||||
|
||||
@@ -22,6 +22,10 @@ nonisolated extension UNNotificationContent {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventIdentifier] as? String
|
||||
}
|
||||
|
||||
@objc var eventDate: Date? {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventDate] as? Date
|
||||
}
|
||||
|
||||
@objc var pusherNotificationClientIdentifier: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.pusherNotificationClientIdentifier] as? String
|
||||
}
|
||||
@@ -59,6 +63,15 @@ nonisolated extension UNMutableNotificationContent {
|
||||
}
|
||||
}
|
||||
|
||||
override var eventDate: Date? {
|
||||
get {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventDate] as? Date
|
||||
}
|
||||
set {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventDate] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
override var threadRootEventID: String? {
|
||||
get {
|
||||
userInfo[NotificationConstants.UserInfoKey.threadRootEventIdentifier] as? String
|
||||
|
||||
@@ -151,7 +151,10 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
return false
|
||||
}
|
||||
|
||||
return notification.date <= lastMessageDate
|
||||
// The delivery date is later than the event's so only use it for notifications without an event date.
|
||||
let notificationDate = notification.request.content.eventDate ?? notification.date
|
||||
// Truncated to seconds to match `RoomSummary.lastMessageDate`.
|
||||
return notificationDate.timeIntervalSince1970.rounded(.down) <= lastMessageDate.timeIntervalSince1970
|
||||
}
|
||||
.map(\.request.identifier)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ nonisolated enum NotificationConstants {
|
||||
enum UserInfoKey {
|
||||
static let roomIdentifier = "room_id"
|
||||
static let eventIdentifier = "event_id"
|
||||
static let eventDate = "event_date"
|
||||
static let threadRootEventIdentifier = "thread_root_event_id"
|
||||
static let pusherNotificationClientIdentifier = "pusher_notification_client_identifier"
|
||||
static let receiverIdentifier = "receiver_id"
|
||||
|
||||
Reference in New Issue
Block a user