mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Guard resource parsing
This commit is contained in:
parent
251e1ecee7
commit
588f5cb8c0
@ -177,7 +177,9 @@ public final class EmojiKeyboardItemLayer: MultiAnimationRenderTarget {
|
||||
|
||||
switch content {
|
||||
case let .animation(animationData):
|
||||
let animationDataResource = animationData.resource._parse()
|
||||
guard let animationDataResource = animationData.resource._parse() else {
|
||||
return
|
||||
}
|
||||
|
||||
let loadAnimation: () -> Void = { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
|
@ -65,12 +65,15 @@ public final class EntityKeyboardAnimationData: Equatable {
|
||||
case stickerPackThumbnail(id: Int64, accessHash: Int64, info: StickerPackCollectionInfo.Accessor)
|
||||
case file(PartialMediaReference?, TelegramMediaFile.Accessor)
|
||||
|
||||
func _parse() -> MediaResourceReference {
|
||||
func _parse() -> MediaResourceReference? {
|
||||
switch self {
|
||||
case let .resource(resource):
|
||||
return resource
|
||||
case let .stickerPackThumbnail(id, accessHash, info):
|
||||
return .stickerPackThumbnail(stickerPack: .id(id: id, accessHash: accessHash), resource: info._parse().thumbnail!.resource)
|
||||
guard let thumbnail = info._parse().thumbnail else {
|
||||
return nil
|
||||
}
|
||||
return .stickerPackThumbnail(stickerPack: .id(id: id, accessHash: accessHash), resource: thumbnail.resource)
|
||||
case let .file(partialReference, file):
|
||||
let file = file._parse()
|
||||
if let partialReference {
|
||||
@ -1740,7 +1743,9 @@ public final class EmojiPagerContentComponent: Component {
|
||||
})
|
||||
}
|
||||
|
||||
component.animationRenderer.setFrameIndex(itemId: animationData.resource._parse().resource.id.stringRepresentation, size: itemLayer.pixelSize, frameIndex: sourceItem.frameIndex, placeholder: sourceItem.placeholder)
|
||||
if let resource = animationData.resource._parse() {
|
||||
component.animationRenderer.setFrameIndex(itemId: resource.resource.id.stringRepresentation, size: itemLayer.pixelSize, frameIndex: sourceItem.frameIndex, placeholder: sourceItem.placeholder)
|
||||
}
|
||||
} else {
|
||||
let distance = itemLayer.position.y - itemLayout.frame(groupIndex: 0, itemIndex: 0).midY
|
||||
let maxDistance = self.bounds.height
|
||||
|
Loading…
x
Reference in New Issue
Block a user