Fixed animated sticker loading in panels

This commit is contained in:
Ilya Laktyushin 2019-07-01 20:36:17 +02:00
parent e9520a2de5
commit 4bd653c0c0
3 changed files with 7 additions and 7 deletions

View File

@ -92,8 +92,6 @@ final class HorizontalStickerGridItemNode: GridItemNode {
if self.currentState == nil || self.currentState!.0 !== account || self.currentState!.1.file.id != item.file.id {
if let dimensions = item.file.dimensions {
if item.file.isAnimatedSticker {
self.stickerFetchedDisposable.set(nil)
let animationNode: AnimatedStickerNode
if let currentAnimationNode = self.animationNode {
animationNode = currentAnimationNode
@ -111,7 +109,6 @@ final class HorizontalStickerGridItemNode: GridItemNode {
} else {
self.imageNode.alpha = 1.0
self.imageNode.setSignal(chatMessageSticker(account: account, file: item.file, small: true))
self.stickerFetchedDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start())
if let currentAnimationNode = self.animationNode {
self.animationNode = nil
@ -119,6 +116,8 @@ final class HorizontalStickerGridItemNode: GridItemNode {
}
}
self.stickerFetchedDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start())
self.currentState = (account, item, dimensions)
self.setNeedsLayout()
}

View File

@ -209,4 +209,3 @@ public class InviteContactsController: ViewController, MFMessageComposeViewContr
self.contactsNode.selectionState = self.contactsNode.selectionState.withClearedSelection()
}
}

View File

@ -91,13 +91,15 @@ private final class TrendingTopItemNode: ASDisplayNode {
self.addSubnode(self.imageNode)
}
deinit {
self.loadDisposable.dispose()
}
func setup(account: Account, item: StickerPackItem, itemSize: CGSize, synchronousLoads: Bool) {
self.file = item.file
self.itemSize = itemSize
if item.file.isAnimatedSticker {
self.loadDisposable.set(nil)
let animationNode: AnimatedStickerNode
if let currentAnimationNode = self.animationNode {
animationNode = currentAnimationNode
@ -114,13 +116,13 @@ private final class TrendingTopItemNode: ASDisplayNode {
animationNode.setup(account: account, resource: item.file.resource, width: 140, height: 140, mode: .cached)
} else {
self.imageNode.setSignal(chatMessageSticker(account: account, file: item.file, small: true, synchronousLoad: synchronousLoads), attemptSynchronously: synchronousLoads)
self.loadDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start())
if let currentAnimationNode = self.animationNode {
self.animationNode = nil
currentAnimationNode.removeFromSupernode()
}
}
self.loadDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start())
}
func updatePreviewing(animated: Bool, isPreviewing: Bool) {