mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various improvements
This commit is contained in:
@@ -10,13 +10,13 @@ public enum CachedStickerPackResult {
|
||||
}
|
||||
|
||||
func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo, items: [StickerPackItem], reference: StickerPackReference? = nil) {
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: entry)
|
||||
}
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName.lowercased())), entry: entry)
|
||||
guard let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) else {
|
||||
return
|
||||
}
|
||||
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: entry)
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName.lowercased())), entry: entry)
|
||||
|
||||
if let reference = reference {
|
||||
var namespace: Int32?
|
||||
var id: ItemCollectionId.Id?
|
||||
@@ -57,9 +57,7 @@ func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo,
|
||||
id = info.id.id
|
||||
}
|
||||
if let namespace = namespace, let id = id {
|
||||
if let entry = CodableEntry(CachedStickerPack(info: info, items: items, hash: info.hash)) {
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))), entry: entry)
|
||||
}
|
||||
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))), entry: entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,11 @@ func _internal_deleteStickerSet(account: Account, packReference: StickerPackRefe
|
||||
}
|
||||
|> mapToSignal { _ in
|
||||
return account.postbox.transaction { transaction in
|
||||
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
|
||||
transaction.removeItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)))
|
||||
transaction.removeItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName.lowercased())))
|
||||
}
|
||||
|
||||
if case let .id(id, _) = packReference {
|
||||
transaction.removeItemCollection(collectionId: ItemCollectionId(namespace: Namespaces.ItemCollection.CloudStickerPacks, id: id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user