Status and reaction improvements

This commit is contained in:
Ali
2022-09-05 03:57:37 +04:00
parent e4f1c6aa72
commit 7020c5ed05
33 changed files with 907 additions and 67 deletions

View File

@@ -0,0 +1,45 @@
import Foundation
final class MutablePeerTimeoutAttributesView: MutablePostboxView {
fileprivate var minValue: (peerId: PeerId, timestamp: UInt32)?
init(postbox: PostboxImpl) {
self.minValue = postbox.peerTimeoutPropertiesTable.min()
}
func replay(postbox: PostboxImpl, transaction: PostboxTransaction) -> Bool {
var updated = false
if transaction.updatedPeerTimeoutAttributes {
let minValue = postbox.peerTimeoutPropertiesTable.min()
if self.minValue?.0 != minValue?.0 || self.minValue?.1 != minValue?.1 {
updated = true
self.minValue = minValue
}
}
return updated
}
func refreshDueToExternalTransaction(postbox: PostboxImpl) -> Bool {
let minValue = postbox.peerTimeoutPropertiesTable.min()
if self.minValue?.0 != minValue?.0 || self.minValue?.1 != minValue?.1 {
self.minValue = minValue
return true
} else {
return false
}
}
func immutableView() -> PostboxView {
return PeerTimeoutAttributesView(self)
}
}
public final class PeerTimeoutAttributesView: PostboxView {
public let minValue: (peerId: PeerId, timestamp: UInt32)?
init(_ view: MutablePeerTimeoutAttributesView) {
self.minValue = view.minValue
}
}