mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Remove delivered notifications for rooms that have meantime become fully read and have messages newer than what's delivered
- this is a best effort solution to cleanup outdated notifications when using multiple clients and reading them elsewhere
This commit is contained in:
committed by
Stefan Ceriu
parent
e14672e1f6
commit
899c33a5ad
@@ -12026,6 +12026,47 @@ class NotificationManagerMock: NotificationManagerProtocol, @unchecked Sendable
|
||||
}
|
||||
await removeDeliveredMessageNotificationsForClosure?(roomID)
|
||||
}
|
||||
//MARK: - removeDeliveredNotificationsForFullyReadRooms
|
||||
|
||||
var removeDeliveredNotificationsForFullyReadRoomsUnderlyingCallsCount = 0
|
||||
var removeDeliveredNotificationsForFullyReadRoomsCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return removeDeliveredNotificationsForFullyReadRoomsUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = removeDeliveredNotificationsForFullyReadRoomsUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
removeDeliveredNotificationsForFullyReadRoomsUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
removeDeliveredNotificationsForFullyReadRoomsUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var removeDeliveredNotificationsForFullyReadRoomsCalled: Bool {
|
||||
return removeDeliveredNotificationsForFullyReadRoomsCallsCount > 0
|
||||
}
|
||||
var removeDeliveredNotificationsForFullyReadRoomsReceivedRooms: [RoomSummary]?
|
||||
var removeDeliveredNotificationsForFullyReadRoomsReceivedInvocations: [[RoomSummary]] = []
|
||||
var removeDeliveredNotificationsForFullyReadRoomsClosure: (([RoomSummary]) async -> Void)?
|
||||
|
||||
func removeDeliveredNotificationsForFullyReadRooms(_ rooms: [RoomSummary]) async {
|
||||
removeDeliveredNotificationsForFullyReadRoomsCallsCount += 1
|
||||
removeDeliveredNotificationsForFullyReadRoomsReceivedRooms = rooms
|
||||
DispatchQueue.main.async {
|
||||
self.removeDeliveredNotificationsForFullyReadRoomsReceivedInvocations.append(rooms)
|
||||
}
|
||||
await removeDeliveredNotificationsForFullyReadRoomsClosure?(rooms)
|
||||
}
|
||||
}
|
||||
class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol, @unchecked Sendable {
|
||||
var callbacks: PassthroughSubject<NotificationSettingsProxyCallback, Never> {
|
||||
|
||||
@@ -79,6 +79,7 @@ extension RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("I do not wish to take the trouble to understand mysticism"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "14:56",
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -102,6 +103,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("I do not wish to take the trouble to understand mysticism"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "14:56",
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -120,6 +122,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: .mockMXCAvatar,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("How do you see the Emperor then? You think he keeps office hours?"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "2:56 PM",
|
||||
unreadMessagesCount: 2,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -138,6 +141,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: try? AttributedString(markdown: "He certainly seemed no *mental genius* to me"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "Some time ago",
|
||||
unreadMessagesCount: 3,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -156,6 +160,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("There's an archaic measure of time that's called the month"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "Just now",
|
||||
unreadMessagesCount: 2,
|
||||
unreadMentionsCount: 2,
|
||||
@@ -174,6 +179,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("Clearly, if Earth is powerful enough to do that, it might also be capable of adjusting minds in order to force belief in its radioactivity"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "1986",
|
||||
unreadMessagesCount: 1,
|
||||
unreadMentionsCount: 1,
|
||||
@@ -192,6 +198,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: AttributedString("Are you groping for the word 'paranoia'?"),
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: "きょうはじゅういちがつじゅういちにちです",
|
||||
unreadMessagesCount: 6,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -210,6 +217,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: nil,
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -261,6 +269,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: .mockMXCAvatar,
|
||||
heroes: [],
|
||||
lastMessage: nil,
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
@@ -279,6 +288,7 @@ extension Array where Element == RoomSummary {
|
||||
avatarURL: nil,
|
||||
heroes: [],
|
||||
lastMessage: nil,
|
||||
lastMessageDate: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadMessagesCount: 0,
|
||||
unreadMentionsCount: 0,
|
||||
|
||||
Reference in New Issue
Block a user