mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Status and reaction improvements
This commit is contained in:
45
submodules/Postbox/Sources/PeerTimeoutAttributesView.swift
Normal file
45
submodules/Postbox/Sources/PeerTimeoutAttributesView.swift
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user