mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Don't generate videos for single frame animated stickers
This commit is contained in:
parent
01067bd1f2
commit
d5ea353b92
@ -147,6 +147,9 @@ public final class DrawingStickerEntityView: DrawingEntityView {
|
|||||||
self?.imageNode.isHidden = true
|
self?.imageNode.isHidden = true
|
||||||
|
|
||||||
if let animationNode = animationNode {
|
if let animationNode = animationNode {
|
||||||
|
if animationNode.currentFrameCount == 1 {
|
||||||
|
self?.stickerEntity.isExplicitlyStatic = true
|
||||||
|
}
|
||||||
let _ = (animationNode.status
|
let _ = (animationNode.status
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||||
|
@ -62,6 +62,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
case scale
|
case scale
|
||||||
case rotation
|
case rotation
|
||||||
case mirrored
|
case mirrored
|
||||||
|
case isExplicitlyStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
public let uuid: UUID
|
public let uuid: UUID
|
||||||
@ -73,6 +74,8 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
public var rotation: CGFloat
|
public var rotation: CGFloat
|
||||||
public var mirrored: Bool
|
public var mirrored: Bool
|
||||||
|
|
||||||
|
public var isExplicitlyStatic: Bool
|
||||||
|
|
||||||
public var color: DrawingColor = DrawingColor.clear
|
public var color: DrawingColor = DrawingColor.clear
|
||||||
public var lineWidth: CGFloat = 0.0
|
public var lineWidth: CGFloat = 0.0
|
||||||
|
|
||||||
@ -88,7 +91,11 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
public var isAnimated: Bool {
|
public var isAnimated: Bool {
|
||||||
switch self.content {
|
switch self.content {
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
|
if self.isExplicitlyStatic {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
return file.isAnimatedSticker || file.isVideoSticker || file.mimeType == "video/webm"
|
return file.isAnimatedSticker || file.isVideoSticker || file.mimeType == "video/webm"
|
||||||
|
}
|
||||||
case .image:
|
case .image:
|
||||||
return false
|
return false
|
||||||
case .video:
|
case .video:
|
||||||
@ -123,6 +130,8 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
self.scale = 1.0
|
self.scale = 1.0
|
||||||
self.rotation = 0.0
|
self.rotation = 0.0
|
||||||
self.mirrored = false
|
self.mirrored = false
|
||||||
|
|
||||||
|
self.isExplicitlyStatic = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
@ -150,6 +159,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
self.scale = try container.decode(CGFloat.self, forKey: .scale)
|
self.scale = try container.decode(CGFloat.self, forKey: .scale)
|
||||||
self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
|
self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
|
||||||
self.mirrored = try container.decode(Bool.self, forKey: .mirrored)
|
self.mirrored = try container.decode(Bool.self, forKey: .mirrored)
|
||||||
|
self.isExplicitlyStatic = try container.decodeIfPresent(Bool.self, forKey: .isExplicitlyStatic) ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -185,6 +195,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
try container.encode(self.scale, forKey: .scale)
|
try container.encode(self.scale, forKey: .scale)
|
||||||
try container.encode(self.rotation, forKey: .rotation)
|
try container.encode(self.rotation, forKey: .rotation)
|
||||||
try container.encode(self.mirrored, forKey: .mirrored)
|
try container.encode(self.mirrored, forKey: .mirrored)
|
||||||
|
try container.encode(self.isExplicitlyStatic, forKey: .isExplicitlyStatic)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func duplicate() -> DrawingEntity {
|
public func duplicate() -> DrawingEntity {
|
||||||
@ -194,6 +205,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
newEntity.scale = self.scale
|
newEntity.scale = self.scale
|
||||||
newEntity.rotation = self.rotation
|
newEntity.rotation = self.rotation
|
||||||
newEntity.mirrored = self.mirrored
|
newEntity.mirrored = self.mirrored
|
||||||
|
newEntity.isExplicitlyStatic = self.isExplicitlyStatic
|
||||||
return newEntity
|
return newEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +234,9 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
|
|||||||
if self.mirrored != other.mirrored {
|
if self.mirrored != other.mirrored {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if self.isExplicitlyStatic != other.isExplicitlyStatic {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user