Don't generate videos for single frame animated stickers

This commit is contained in:
Ilya Laktyushin 2023-07-05 00:34:40 +02:00
parent 01067bd1f2
commit d5ea353b92
2 changed files with 20 additions and 2 deletions

View File

@ -147,6 +147,9 @@ public final class DrawingStickerEntityView: DrawingEntityView {
self?.imageNode.isHidden = true
if let animationNode = animationNode {
if animationNode.currentFrameCount == 1 {
self?.stickerEntity.isExplicitlyStatic = true
}
let _ = (animationNode.status
|> take(1)
|> deliverOnMainQueue).start(next: { [weak self] status in

View File

@ -62,6 +62,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
case scale
case rotation
case mirrored
case isExplicitlyStatic
}
public let uuid: UUID
@ -73,6 +74,8 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
public var rotation: CGFloat
public var mirrored: Bool
public var isExplicitlyStatic: Bool
public var color: DrawingColor = DrawingColor.clear
public var lineWidth: CGFloat = 0.0
@ -88,7 +91,11 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
public var isAnimated: Bool {
switch self.content {
case let .file(file):
if self.isExplicitlyStatic {
return false
} else {
return file.isAnimatedSticker || file.isVideoSticker || file.mimeType == "video/webm"
}
case .image:
return false
case .video:
@ -123,6 +130,8 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
self.scale = 1.0
self.rotation = 0.0
self.mirrored = false
self.isExplicitlyStatic = false
}
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.rotation = try container.decode(CGFloat.self, forKey: .rotation)
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 {
@ -185,6 +195,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
try container.encode(self.scale, forKey: .scale)
try container.encode(self.rotation, forKey: .rotation)
try container.encode(self.mirrored, forKey: .mirrored)
try container.encode(self.isExplicitlyStatic, forKey: .isExplicitlyStatic)
}
public func duplicate() -> DrawingEntity {
@ -194,6 +205,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
newEntity.scale = self.scale
newEntity.rotation = self.rotation
newEntity.mirrored = self.mirrored
newEntity.isExplicitlyStatic = self.isExplicitlyStatic
return newEntity
}
@ -222,6 +234,9 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
if self.mirrored != other.mirrored {
return false
}
if self.isExplicitlyStatic != other.isExplicitlyStatic {
return false
}
return true
}
}