Various fixes

This commit is contained in:
Ilya Laktyushin
2022-02-27 17:19:12 +04:00
parent f9f9f20141
commit 0874d92b11
15 changed files with 109 additions and 24 deletions

View File

@@ -58,10 +58,15 @@ final class HorizontalStickerGridItemNode: GridItemNode {
private var currentIsPreviewing: Bool = false
private var setupTimestamp: Double?
override var isVisibleInGrid: Bool {
didSet {
if oldValue != self.isVisibleInGrid {
if self.isVisibleInGrid {
if self.setupTimestamp == nil {
self.setupTimestamp = CACurrentMediaTime()
}
self.animationNode?.visibility = true
} else {
self.animationNode?.visibility = false
@@ -158,7 +163,20 @@ final class HorizontalStickerGridItemNode: GridItemNode {
self.imageNode.setSignal(chatMessageAnimatedSticker(postbox: account.postbox, file: item.file, small: true, size: fittedDimensions, synchronousLoad: false))
}
animationNode.started = { [weak self] in
self?.imageNode.alpha = 0.0
guard let strongSelf = self else {
return
}
strongSelf.imageNode.alpha = 0.0
let current = CACurrentMediaTime()
if let setupTimestamp = strongSelf.setupTimestamp, current - setupTimestamp > 0.3 {
if let placeholderNode = strongSelf.placeholderNode, !placeholderNode.alpha.isZero {
strongSelf.removePlaceholder(animated: true)
}
} else {
strongSelf.removePlaceholder(animated: false)
}
}
animationNode.setup(source: AnimatedStickerResourceSource(account: account, resource: item.file.resource, isVideo: item.file.isVideoSticker), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .cached)