mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Refactor SyncCore
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
import PostboxMac
|
||||
#else
|
||||
import Postbox
|
||||
#endif
|
||||
|
||||
public class OutgoingScheduleInfoMessageAttribute: MessageAttribute {
|
||||
public let scheduleTime: Int32
|
||||
|
||||
public init(scheduleTime: Int32) {
|
||||
self.scheduleTime = scheduleTime
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.scheduleTime = decoder.decodeInt32ForKey("t", orElse: 0)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(scheduleTime, forKey: "t")
|
||||
}
|
||||
|
||||
public func withUpdatedScheduleTime(_ scheduleTime: Int32) -> OutgoingScheduleInfoMessageAttribute {
|
||||
return OutgoingScheduleInfoMessageAttribute(scheduleTime: scheduleTime)
|
||||
}
|
||||
}
|
||||
|
||||
public extension Message {
|
||||
var scheduleTime: Int32? {
|
||||
for attribute in self.attributes {
|
||||
if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute {
|
||||
return attribute.scheduleTime
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user