mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -250,6 +250,7 @@ public final class PendingReactionsMessageAttribute: MessageAttribute {
|
||||
public let accountPeerId: PeerId?
|
||||
public let reactions: [PendingReaction]
|
||||
public let isLarge: Bool
|
||||
public let storeAsRecentlyUsed: Bool
|
||||
|
||||
public var associatedPeerIds: [PeerId] {
|
||||
if let accountPeerId = self.accountPeerId {
|
||||
@@ -277,16 +278,18 @@ public final class PendingReactionsMessageAttribute: MessageAttribute {
|
||||
return result
|
||||
}
|
||||
|
||||
public init(accountPeerId: PeerId?, reactions: [PendingReaction], isLarge: Bool) {
|
||||
public init(accountPeerId: PeerId?, reactions: [PendingReaction], isLarge: Bool, storeAsRecentlyUsed: Bool) {
|
||||
self.accountPeerId = accountPeerId
|
||||
self.reactions = reactions
|
||||
self.isLarge = isLarge
|
||||
self.storeAsRecentlyUsed = storeAsRecentlyUsed
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.accountPeerId = decoder.decodeOptionalInt64ForKey("ap").flatMap(PeerId.init)
|
||||
self.reactions = decoder.decodeObjectArrayWithDecoderForKey("reac")
|
||||
self.isLarge = decoder.decodeInt32ForKey("l", orElse: 0) != 0
|
||||
self.storeAsRecentlyUsed = decoder.decodeInt32ForKey("used", orElse: 0) != 0
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@@ -299,5 +302,6 @@ public final class PendingReactionsMessageAttribute: MessageAttribute {
|
||||
encoder.encodeObjectArray(self.reactions, forKey: "reac")
|
||||
|
||||
encoder.encodeInt32(self.isLarge ? 1 : 0, forKey: "l")
|
||||
encoder.encodeInt32(self.storeAsRecentlyUsed ? 1 : 0, forKey: "used")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,6 +522,15 @@ public final class TelegramMediaFile: Media, Equatable, Codable {
|
||||
return false
|
||||
}
|
||||
|
||||
public var isStaticEmoji: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case .CustomEmoji = attribute {
|
||||
return self.mimeType == "image/webp"
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public var isVideo: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case .Video = attribute {
|
||||
|
||||
Reference in New Issue
Block a user