fix reactions push

This commit is contained in:
overtake
2021-12-24 19:22:50 +04:00
parent 447e58f6af
commit b128a7d0fb
3 changed files with 69 additions and 44 deletions

View File

@@ -105,8 +105,8 @@ public final class AccountStateManager {
return self.notificationMessagesPipe.signal()
}
private let reactionNotificationsPipe = ValuePipe<[(reactionAuthor: Peer, message: Message)]>()
public var reactionNotifications: Signal<[(reactionAuthor: Peer, message: Message)], NoError> {
private let reactionNotificationsPipe = ValuePipe<[(reactionAuthor: Peer, reaction: String, message: Message, timestamp: Int32)]>()
public var reactionNotifications: Signal<[(reactionAuthor: Peer, reaction: String, message: Message, timestamp: Int32)], NoError> {
return self.reactionNotificationsPipe.signal()
}
@@ -746,16 +746,15 @@ public final class AccountStateManager {
let timestamp = Int32(Date().timeIntervalSince1970)
let minReactionTimestamp = timestamp - 20
let reactionEvents = events.addedReactionEvents.compactMap { event -> (reactionAuthor: Peer, message: Message)? in
let reactionEvents = events.addedReactionEvents.compactMap { event -> (reactionAuthor: Peer, reaction: String, message: Message, timestamp: Int32)? in
if event.timestamp >= minReactionTimestamp {
return (event.reactionAuthor, event.message)
return (event.reactionAuthor, event.reaction, event.message, event.timestamp)
} else {
return nil
}
}
if !reactionEvents.isEmpty {
self.reactionNotificationsPipe.putNext(reactionEvents)
}
self.reactionNotificationsPipe.putNext(reactionEvents)
if !events.displayAlerts.isEmpty {
self.displayAlertsPipe.putNext(events.displayAlerts)