diff --git a/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift b/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift index 6c796857da..889af3cae8 100644 --- a/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift +++ b/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift @@ -60,6 +60,7 @@ public enum AnimatedStickerPlaybackPosition { public enum AnimatedStickerPlaybackMode { case once + case count(Int) case loop case still(AnimatedStickerPlaybackPosition) } @@ -757,6 +758,7 @@ public final class AnimatedStickerNode: ASDisplayNode { private var renderer: (AnimationRenderer & ASDisplayNode)? public var isPlaying: Bool = false + private var currentLoopCount: Int = 0 private var canDisplayFirstFrame: Bool = false private var playbackMode: AnimatedStickerPlaybackMode = .loop @@ -910,8 +912,14 @@ public final class AnimatedStickerNode: ASDisplayNode { private var isSetUpForPlayback = false public func play(firstFrame: Bool = false) { - if case .once = self.playbackMode { + switch self.playbackMode { + case .once: self.isPlaying = true + case .count: + self.currentLoopCount = 0 + self.isPlaying = true + default: + break } if self.isSetUpForPlayback { let directData = self.directData @@ -976,6 +984,11 @@ public final class AnimatedStickerNode: ASDisplayNode { var stopNow = false if case .once = strongSelf.playbackMode { stopNow = true + } else if case let .count(count) = strongSelf.playbackMode { + strongSelf.currentLoopCount += 1 + if count <= strongSelf.currentLoopCount { + stopNow = true + } } else if strongSelf.stopAtNearestLoop { stopNow = true } @@ -1061,6 +1074,11 @@ public final class AnimatedStickerNode: ASDisplayNode { var stopNow = false if case .once = strongSelf.playbackMode { stopNow = true + } else if case let .count(count) = strongSelf.playbackMode { + strongSelf.currentLoopCount += 1 + if count <= strongSelf.currentLoopCount { + stopNow = true + } } else if strongSelf.stopAtNearestLoop { stopNow = true } diff --git a/submodules/ChatListFilterSettingsHeaderItem/Sources/ChatListFilterSettingsHeaderItem.swift b/submodules/ChatListFilterSettingsHeaderItem/Sources/ChatListFilterSettingsHeaderItem.swift index 078a24be76..1aa9ead2c4 100644 --- a/submodules/ChatListFilterSettingsHeaderItem/Sources/ChatListFilterSettingsHeaderItem.swift +++ b/submodules/ChatListFilterSettingsHeaderItem/Sources/ChatListFilterSettingsHeaderItem.swift @@ -126,7 +126,7 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode { animationName = "MessageAutoRemove" size = 260 insetDifference = 120 - playbackMode = .once + playbackMode = .count(2) additionalBottomInset = isHidden ? 8.0 : 16.0 }