Update API

This commit is contained in:
Isaac 2025-06-29 18:22:00 +02:00
parent 73062c70e6
commit e79e1b2cf9
3 changed files with 33 additions and 0 deletions

View File

@ -62,6 +62,7 @@ public struct Namespaces {
public static let CloudIconStatusEmoji: Int32 = 10
public static let CloudIconTopicEmoji: Int32 = 11
public static let CloudIconChannelStatusEmoji: Int32 = 12
public static let CloudTonGifts: Int32 = 13
}
public struct OrderedItemList {

View File

@ -55,6 +55,9 @@ func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo,
case .name:
namespace = info.id.namespace
id = info.id.id
case .tonGifts:
namespace = Namespaces.ItemCollection.CloudTonGifts
id = 0
}
if let namespace = namespace, let id = id {
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))), entry: entry)
@ -159,6 +162,20 @@ func _internal_cachedStickerPack(postbox: Postbox, network: Network, reference:
} else {
return (.fetching, true, nil)
}
case .tonGifts:
let namespace = Namespaces.ItemCollection.CloudTonGifts
let id: ItemCollectionId.Id = 0
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
previousHash = cached.hash
let current: CachedStickerPackResult = .result(info, cached.items, false)
if cached.hash != info.hash {
return (current, true, previousHash)
} else {
return (current, false, previousHash)
}
} else {
return (.fetching, true, nil)
}
case .emojiGenericAnimations:
let namespace = Namespaces.ItemCollection.CloudEmojiGenericAnimations
let id: ItemCollectionId.Id = 0
@ -324,6 +341,18 @@ func cachedStickerPack(transaction: Transaction, reference: StickerPackReference
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
return (info, cached.items, false)
}
case .tonGifts:
let namespace = Namespaces.ItemCollection.CloudTonGifts
let id: ItemCollectionId.Id = 0
if let currentInfo = transaction.getItemCollectionInfo(collectionId: ItemCollectionId(namespace: namespace, id: id)) as? StickerPackCollectionInfo {
let items = transaction.getItemCollectionItems(collectionId: ItemCollectionId(namespace: namespace, id: id))
if !items.isEmpty {
return (StickerPackCollectionInfo.Accessor(currentInfo), items.compactMap { $0 as? StickerPackItem }, true)
}
}
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
return (info, cached.items, false)
}
case .emojiGenericAnimations:
let namespace = Namespaces.ItemCollection.CloudEmojiGenericAnimations
let id: ItemCollectionId.Id = 0

View File

@ -58,6 +58,9 @@ func _internal_requestStickerSet(postbox: Postbox, network: Network, reference:
case .iconTopicEmoji:
collectionId = nil
input = .inputStickerSetEmojiDefaultTopicIcons
case .tonGifts:
collectionId = nil
input = .inputStickerSetTonGifts
}
let localSignal: (ItemCollectionId) -> Signal<(ItemCollectionInfo, [ItemCollectionItem])?, NoError> = { collectionId in