File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 88
99NS_ASSUME_NONNULL_BEGIN
1010
11+
12+ double const OWSExpirationTimerViewBlinkingSeconds = 2 ;
13+
1114@interface OWSExpirationTimerView ()
1215
1316@property (nonatomic ) uint32_t initialDurationSeconds;
@@ -142,15 +145,27 @@ - (void)startTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds
142145 [maskLayer addAnimation: revealAnimation forKey: @" revealAnimation" ];
143146 maskLayer.position = finalPosition; // don't snap back
144147
145- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, ((long long )secondsLeft - 2 ) * (long long )NSEC_PER_SEC),
148+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW,
149+ (long long )((secondsLeft - OWSExpirationTimerViewBlinkingSeconds) * NSEC_PER_SEC)),
146150 dispatch_get_main_queue (),
147151 ^{
148152 [self startBlinking ];
149153 });
150154}
151155
156+ - (BOOL )itIsTimeToBlink
157+ {
158+ double secondsLeft = (double )self.expiresAtSeconds - [NSDate new ].timeIntervalSince1970 ;
159+ return secondsLeft <= OWSExpirationTimerViewBlinkingSeconds;
160+ }
161+
152162- (void )startBlinking
153163{
164+ if (![self itIsTimeToBlink ]) {
165+ DDLogVerbose (@" Refusing to start blinking too early. Reused cell?" );
166+ return ;
167+ }
168+
154169 CABasicAnimation *blinkAnimation = [CABasicAnimation animationWithKeyPath: @" opacity" ];
155170 blinkAnimation.duration = 0.5 ;
156171 blinkAnimation.fromValue = @(1.0 );
You can’t perform that action at this time.
0 commit comments