Update API

This commit is contained in:
Ali
2022-08-25 20:37:09 +03:00
parent baad5e1eb8
commit 1d2ad0f5de
13 changed files with 157 additions and 64 deletions

View File

@@ -5,7 +5,7 @@ public struct CacheStorageSettings: Codable, Equatable {
public let defaultCacheStorageLimitGigabytes: Int32
public static var defaultSettings: CacheStorageSettings {
return CacheStorageSettings(defaultCacheStorageTimeout: Int32.max, defaultCacheStorageLimitGigabytes: Int32.max)
return CacheStorageSettings(defaultCacheStorageTimeout: Int32.max, defaultCacheStorageLimitGigabytes: 8 * 1024 * 1024)
}
public init(defaultCacheStorageTimeout: Int32, defaultCacheStorageLimitGigabytes: Int32) {
@@ -17,7 +17,14 @@ public struct CacheStorageSettings: Codable, Equatable {
let container = try decoder.container(keyedBy: StringCodingKey.self)
self.defaultCacheStorageTimeout = (try? container.decode(Int32.self, forKey: "dt")) ?? Int32.max
self.defaultCacheStorageLimitGigabytes = (try? container.decode(Int32.self, forKey: "dl")) ?? Int32.max
if let legacyValue = try container.decodeIfPresent(Int32.self, forKey: "dl") {
self.defaultCacheStorageLimitGigabytes = legacyValue
} else if let value = try container.decodeIfPresent(Int32.self, forKey: "sizeLimit") {
self.defaultCacheStorageLimitGigabytes = value
} else {
self.defaultCacheStorageLimitGigabytes = 8 * 1024 * 1024
}
}
public func encode(to encoder: Encoder) throws {

View File

@@ -1,5 +1,6 @@
import Foundation
import Postbox
import TelegramApi
public final class CachedPeerBotInfo: PostboxCoding, Equatable {
public let peerId: PeerId
@@ -82,6 +83,19 @@ public enum PeerAllowedReactions: Equatable, Codable {
}
}
extension PeerAllowedReactions {
init(apiReactions: Api.ChatReactions) {
switch apiReactions {
case .chatReactionsAll:
self = .all
case let .chatReactionsSome(reactions):
self = .limited(reactions.compactMap(MessageReaction.Reaction.init(apiReaction:)))
case .chatReactionsNone:
self = .empty
}
}
}
public final class CachedGroupData: CachedPeerData {
public let participants: CachedGroupParticipants?
public let exportedInvitation: ExportedInvitation?