Fixed action buttons overlapping animated sticker

This commit is contained in:
Ilya Laktyushin 2019-07-03 17:16:50 +02:00
parent 2d0cea8a45
commit 51708d526d
2 changed files with 27 additions and 5 deletions

View File

@ -181,12 +181,23 @@ public func searchStickers(account: Account, query: String, scope: SearchSticker
return .single(tempResult)
}
let currentItems = Set<MediaId>(localItems.map { $0.file.fileId })
if let cached = cached {
var cachedItems: [FoundStickerItem] = []
var cachedAnimatedItems: [FoundStickerItem] = []
for file in cached.items {
if !currentItems.contains(file.fileId) {
tempResult.append(FoundStickerItem(file: file, stringRepresentations: []))
if file.isAnimatedSticker {
cachedAnimatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
} else {
cachedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
}
}
}
tempResult.append(contentsOf: cachedAnimatedItems)
tempResult.append(contentsOf: cachedItems)
}
let remote = account.network.request(Api.functions.messages.getStickers(emoticon: query, hash: cached?.hash ?? 0))
@ -197,7 +208,10 @@ public func searchStickers(account: Account, query: String, scope: SearchSticker
return account.postbox.transaction { transaction -> [FoundStickerItem] in
switch result {
case let .stickers(hash, stickers):
var items: [FoundStickerItem] = localItems
var items: [FoundStickerItem] = []
var animatedItems: [FoundStickerItem] = []
var result: [FoundStickerItem] = localItems
let currentItems = Set<MediaId>(items.map { $0.file.fileId })
var files: [TelegramMediaFile] = []
@ -205,13 +219,21 @@ public func searchStickers(account: Account, query: String, scope: SearchSticker
if let file = telegramMediaFileFromApiDocument(sticker), let id = file.id {
files.append(file)
if !currentItems.contains(id) {
items.append(FoundStickerItem(file: file, stringRepresentations: []))
if file.isAnimatedSticker {
animatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
} else {
items.append(FoundStickerItem(file: file, stringRepresentations: []))
}
}
}
}
result.append(contentsOf: animatedItems)
result.append(contentsOf: items)
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerQueryResults, key: CachedStickerQueryResult.cacheKey(query)), entry: CachedStickerQueryResult(items: files, hash: hash), collectionSpec: collectionSpec)
return items
return result
case .stickersNotModified:
break
}

View File

@ -493,7 +493,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
}
let actionButtonsNode = actionButtonsSizeAndApply.1(animated)
let previousFrame = actionButtonsNode.frame
let actionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY - 10.0), size: actionButtonsSizeAndApply.0)
let actionButtonsFrame = CGRect(origin: CGPoint(x: imageFrame.minX, y: imageFrame.maxY), size: actionButtonsSizeAndApply.0)
actionButtonsNode.frame = actionButtonsFrame
if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode