mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Improve list offset tracking
This commit is contained in:
@@ -3,15 +3,18 @@ import Postbox
|
||||
public final class ChannelState: PeerChatState, Equatable, CustomStringConvertible {
|
||||
public let pts: Int32
|
||||
public let invalidatedPts: Int32?
|
||||
public let synchronizedUntilMessageId: Int32?
|
||||
|
||||
public init(pts: Int32, invalidatedPts: Int32?) {
|
||||
public init(pts: Int32, invalidatedPts: Int32?, synchronizedUntilMessageId: Int32?) {
|
||||
self.pts = pts
|
||||
self.invalidatedPts = invalidatedPts
|
||||
self.synchronizedUntilMessageId = synchronizedUntilMessageId
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.pts = decoder.decodeInt32ForKey("pts", orElse: 0)
|
||||
self.invalidatedPts = decoder.decodeOptionalInt32ForKey("ipts")
|
||||
self.synchronizedUntilMessageId = decoder.decodeOptionalInt32ForKey("sumi")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@@ -21,14 +24,23 @@ public final class ChannelState: PeerChatState, Equatable, CustomStringConvertib
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "ipts")
|
||||
}
|
||||
if let synchronizedUntilMessageId = self.synchronizedUntilMessageId {
|
||||
encoder.encodeInt32(synchronizedUntilMessageId, forKey: "sumi")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "sumi")
|
||||
}
|
||||
}
|
||||
|
||||
public func withUpdatedPts(_ pts: Int32) -> ChannelState {
|
||||
return ChannelState(pts: pts, invalidatedPts: self.invalidatedPts)
|
||||
return ChannelState(pts: pts, invalidatedPts: self.invalidatedPts, synchronizedUntilMessageId: self.synchronizedUntilMessageId)
|
||||
}
|
||||
|
||||
public func withUpdatedInvalidatedPts(_ invalidatedPts: Int32?) -> ChannelState {
|
||||
return ChannelState(pts: self.pts, invalidatedPts: invalidatedPts)
|
||||
return ChannelState(pts: self.pts, invalidatedPts: invalidatedPts, synchronizedUntilMessageId: self.synchronizedUntilMessageId)
|
||||
}
|
||||
|
||||
public func withUpdatedSynchronizedUntilMessageId(_ synchronizedUntilMessageId: Int32?) -> ChannelState {
|
||||
return ChannelState(pts: self.pts, invalidatedPts: self.invalidatedPts, synchronizedUntilMessageId: synchronizedUntilMessageId)
|
||||
}
|
||||
|
||||
public func equals(_ other: PeerChatState) -> Bool {
|
||||
@@ -43,6 +55,6 @@ public final class ChannelState: PeerChatState, Equatable, CustomStringConvertib
|
||||
}
|
||||
|
||||
public static func ==(lhs: ChannelState, rhs: ChannelState) -> Bool {
|
||||
return lhs.pts == rhs.pts && lhs.invalidatedPts == rhs.invalidatedPts
|
||||
return lhs.pts == rhs.pts && lhs.invalidatedPts == rhs.invalidatedPts && lhs.synchronizedUntilMessageId == rhs.synchronizedUntilMessageId
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user