mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-08 01:40:09 +00:00
Fix lagging when scrolling through music albums in chats
This commit is contained in:
parent
eed0f5cee6
commit
2e9e017b57
@ -1195,7 +1195,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||||||
strongSelf.currentIconImage = iconImage
|
strongSelf.currentIconImage = iconImage
|
||||||
|
|
||||||
if let updateIconImageSignal, let iconImage, case .albumArt = iconImage {
|
if let updateIconImageSignal, let iconImage, case .albumArt = iconImage {
|
||||||
strongSelf.iconStatusNode.setBackgroundImage(updateIconImageSignal)
|
strongSelf.iconStatusNode.setBackgroundImage(updateIconImageSignal, size: CGSize(width: 40.0, height: 40.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
if let iconImageApply = iconImageApply {
|
if let iconImageApply = iconImageApply {
|
||||||
|
|||||||
@ -864,16 +864,19 @@ public final class SemanticStatusNode: ASControlNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setBackgroundImage(_ image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>) {
|
public func setBackgroundImage(_ image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>, size: CGSize) {
|
||||||
let start = CACurrentMediaTime()
|
let start = CACurrentMediaTime()
|
||||||
self.disposable = combineLatest(queue: Queue.mainQueue(), image, self.hasLayoutPromise.get()).start(next: { [weak self] transform, ready in
|
let imageSignal: Signal<UIImage?, NoError> = image
|
||||||
|
|> map { transform -> UIImage? in
|
||||||
|
let context = transform(TransformImageArguments(corners: ImageCorners(radius: size.width / 2.0), imageSize: size, boundingSize: size, intrinsicInsets: UIEdgeInsets()))
|
||||||
|
return context?.generateImage()
|
||||||
|
}
|
||||||
|
self.disposable = combineLatest(queue: Queue.mainQueue(), imageSignal, self.hasLayoutPromise.get()).start(next: { [weak self] image, ready in
|
||||||
guard let strongSelf = self, ready else {
|
guard let strongSelf = self, ready else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let context = transform(TransformImageArguments(corners: ImageCorners(radius: strongSelf.bounds.width / 2.0), imageSize: strongSelf.bounds.size, boundingSize: strongSelf.bounds.size, intrinsicInsets: UIEdgeInsets()))
|
|
||||||
|
|
||||||
let previousAppearanceContext = strongSelf.appearanceContext
|
let previousAppearanceContext = strongSelf.appearanceContext
|
||||||
strongSelf.appearanceContext = strongSelf.appearanceContext.withUpdatedBackgroundImage(context?.generateImage())
|
strongSelf.appearanceContext = strongSelf.appearanceContext.withUpdatedBackgroundImage(image)
|
||||||
|
|
||||||
if CACurrentMediaTime() - start > 0.3 {
|
if CACurrentMediaTime() - start > 0.3 {
|
||||||
strongSelf.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: nil, previousAppearanceContext: previousAppearanceContext, completion: {})
|
strongSelf.transitionContext = SemanticStatusNodeTransitionContext(startTime: CACurrentMediaTime(), duration: 0.18, previousStateContext: nil, previousAppearanceContext: previousAppearanceContext, completion: {})
|
||||||
@ -915,7 +918,7 @@ public final class SemanticStatusNode: ASControlNode {
|
|||||||
self.displaysAsynchronously = true
|
self.displaysAsynchronously = true
|
||||||
|
|
||||||
if let image {
|
if let image {
|
||||||
self.setBackgroundImage(image)
|
self.setBackgroundImage(image, size: CGSize(width: 44.0, height: 44.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user