Update API

This commit is contained in:
Ilya Laktyushin
2021-11-22 21:56:34 +04:00
parent eef0891e96
commit 48cc049d7b
20 changed files with 174 additions and 56 deletions

View File

@@ -101,11 +101,7 @@ public final class CachedUserData: CachedPeerData {
self.autoremoveTimeout = autoremoveTimeout
self.themeEmoticon = themeEmoticon
var peerIds = Set<PeerId>()
if let requestChatPeerId = peerStatusSettings?.requestChatPeerId {
peerIds.insert(requestChatPeerId)
}
self.peerIds = peerIds
self.peerIds = Set<PeerId>()
var messageIds = Set<MessageId>()
if let pinnedMessageId = self.pinnedMessageId {
@@ -139,11 +135,7 @@ public final class CachedUserData: CachedPeerData {
self.autoremoveTimeout = decoder.decodeObjectForKey("artv", decoder: CachedPeerAutoremoveTimeout.init(decoder:)) as? CachedPeerAutoremoveTimeout ?? .unknown
self.themeEmoticon = decoder.decodeOptionalStringForKey("te")
var peerIds = Set<PeerId>()
if let requestChatPeerId = self.peerStatusSettings?.requestChatPeerId {
peerIds.insert(requestChatPeerId)
}
self.peerIds = peerIds
self.peerIds = Set<PeerId>()
var messageIds = Set<MessageId>()
if let pinnedMessageId = self.pinnedMessageId {

View File

@@ -45,6 +45,7 @@ public struct Namespaces {
public static let CloudAnimatedEmoji: Int32 = 3
public static let CloudDice: Int32 = 4
public static let CloudAnimatedEmojiAnimations: Int32 = 5
public static let CloudAnimatedEmojiReactions: Int32 = 6
}
public struct OrderedItemList {

View File

@@ -21,28 +21,31 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
public var flags: PeerStatusSettings.Flags
public var geoDistance: Int32?
public var requestChatPeerId: PeerId?
public var requestChatTitle: String?
public var requestChatDate: Int32?
public var requestChatIsChannel: Bool?
public init() {
self.flags = PeerStatusSettings.Flags()
self.geoDistance = nil
self.requestChatPeerId = nil
self.requestChatTitle = nil
self.requestChatDate = nil
}
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatPeerId: PeerId? = nil, requestChatDate: Int32? = nil) {
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatTitle: String? = nil, requestChatDate: Int32? = nil, requestChatIsChannel: Bool? = nil) {
self.flags = flags
self.geoDistance = geoDistance
self.requestChatPeerId = requestChatPeerId
self.requestChatTitle = requestChatTitle
self.requestChatDate = requestChatDate
self.requestChatIsChannel = requestChatIsChannel
}
public init(decoder: PostboxDecoder) {
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("flags", orElse: 0))
self.geoDistance = decoder.decodeOptionalInt32ForKey("geoDistance")
self.requestChatPeerId = decoder.decodeOptionalInt64ForKey("requestChatPeerId").map { PeerId($0) }
self.requestChatTitle = decoder.decodeOptionalStringForKey("requestChatTitle")
self.requestChatDate = decoder.decodeOptionalInt32ForKey("requestChatDate")
self.requestChatIsChannel = decoder.decodeOptionalBoolForKey("requestChatIsChannel")
}
public func encode(_ encoder: PostboxEncoder) {
@@ -52,16 +55,21 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
} else {
encoder.encodeNil(forKey: "geoDistance")
}
if let requestChatPeerId = self.requestChatPeerId {
encoder.encodeInt64(requestChatPeerId.toInt64(), forKey: "requestChatPeerId")
if let requestChatTitle = self.requestChatTitle {
encoder.encodeString(requestChatTitle, forKey: "requestChatTitle")
} else {
encoder.encodeNil(forKey: "requestPeerId")
encoder.encodeNil(forKey: "requestChatTitle")
}
if let requestChatDate = self.requestChatDate {
encoder.encodeInt32(requestChatDate, forKey: "requestChatDate")
} else {
encoder.encodeNil(forKey: "requestChatDate")
}
if let requestChatIsChannel = self.requestChatIsChannel {
encoder.encodeBool(requestChatIsChannel, forKey: "requestChatIsChannel")
} else {
encoder.encodeNil(forKey: "requestChatIsChannel")
}
}
public func contains(_ member: PeerStatusSettings.Flags) -> Bool {

View File

@@ -1,4 +1,4 @@
import Foundation
import Foundation
import Postbox
private let typeFileName: Int32 = 0
@@ -17,6 +17,7 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
case animatedEmoji
case dice(String)
case animatedEmojiAnimations
case animatedEmojiReactions
public init(decoder: PostboxDecoder) {
switch decoder.decodeInt32ForKey("r", orElse: 0) {
@@ -30,6 +31,8 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
self = .dice(decoder.decodeStringForKey("e", orElse: "🎲"))
case 4:
self = .animatedEmojiAnimations
case 5:
self = .animatedEmojiReactions
default:
self = .name("")
assertionFailure()
@@ -52,6 +55,8 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
encoder.encodeString(emoji, forKey: "e")
case .animatedEmojiAnimations:
encoder.encodeInt32(4, forKey: "r")
case .animatedEmojiReactions:
encoder.encodeInt32(5, forKey: "r")
}
}
@@ -87,6 +92,12 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
} else {
return false
}
case .animatedEmojiReactions:
if case .animatedEmojiReactions = rhs {
return true
} else {
return false
}
}
}
}